Unibeautify
  • Install
  • Docs
  • Assistant
  • Playground
  • GitHub

›M

A

  • Align Assignments
  • Arrow Parens

B

  • Brace Style
  • Break Chained Methods

C

  • Comma First

E

  • End With Comma
  • End With Newline
  • End With Semicolon

F

  • Force Indentation

I

  • Identifier Case
  • Indent Chained Methods
  • Indent Comments
  • Indent Inner Html
  • Indent Scripts
  • Indent Size
  • Indent Style

J

  • JSLint Happy
  • JSX Brackets

K

  • Keep Array Indentation
  • Keyword Case

M

  • Max Preserve Newlines
  • Multiline Ternary

N

  • Newline Before Tags
  • Newline Between Rules
  • No Leading Zero

O

  • Object Curly Spacing

P

  • Pragma Insert
  • Pragma Require
  • Preserve Newlines

Q

  • Quotes

R

  • Remove Trailing Whitespace

S

  • Selector Separator Newline
  • Space After Anon Function
  • Space Before Conditional
  • Space In Empty Paren
  • Space In Paren

U

  • Unescape Strings
  • Unformatted

W

  • Wrap Attributes
  • Wrap Attributes Indent Size
  • Wrap Line Length
  • Wrap Prose
Edit

Multiline Ternary

Config Key: multiline_ternary

Description: Enforces new lines between the operands of a ternary expression

Available since version: 0.7.0 (Current: npm)

Type: string

Default: "always"

Allowed values: "always" or "always-multiline" or "never"

Support

Edit Beautifiers

Languages: C#, EJS, JSX, Java, JavaScript, Riot, Swig, Twig, TypeScript

Beautifiers: Pretty Diff

Comparison Table

LanguagePretty Diff
C#✅
EJS✅
JSX✅
Java✅
JavaScript✅
Riot✅
Swig✅
Twig✅
TypeScript✅

Examples

Invisible characters are shown with the following symbols:

Carriage Return = ␍; Line Feed = ␊; Tab = ⇥; Whitespace = ·.

Edit C# Example

🚧 Original Code

int·x·=·20,·y·=·10;␊
␊
var·result·=·x·>·y·?·x·:·y;␊
␊
Console.WriteLine(result);␊

🔧 "always"

Using Pretty Diff beautifier:

int·x·=·20,␊
y·=·10;␊
␊
var·result·=·x·>·y␊
··?·x␊
··:·y;␊
␊
Console.WriteLine(result);␊

How to configure A .unibeautify.json file would look like the following:

{
  "C#": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always
===================================================================
--- always  Original
+++ always  Beautified
@@ -1,5 +1,8 @@
-int·x·=·20,·y·=·10;␊
+int·x·=·20,␊
+y·=·10;␊
 ␊
-var·result·=·x·>·y·?·x·:·y;␊
+var·result·=·x·>·y␊
+··?·x␊
+··:·y;␊
 ␊
 Console.WriteLine(result);␊

🔧 "always-multiline"

Using Pretty Diff beautifier:

int·x·=·20,␊
y·=·10;␊
␊
var·result·=·x·>·y␊
··?·x␊
··:·y;␊
␊
Console.WriteLine(result);␊

How to configure A .unibeautify.json file would look like the following:

{
  "C#": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always-multiline",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always-multiline
===================================================================
--- always-multiline    Original
+++ always-multiline    Beautified
@@ -1,5 +1,8 @@
-int·x·=·20,·y·=·10;␊
+int·x·=·20,␊
+y·=·10;␊
 ␊
-var·result·=·x·>·y·?·x·:·y;␊
+var·result·=·x·>·y␊
+··?·x␊
+··:·y;␊
 ␊
 Console.WriteLine(result);␊

🔧 "never"

Using Pretty Diff beautifier:

int·x·=·20,␊
y·=·10;␊
␊
var·result·=·x·>·y·?·x:·y;␊
␊
Console.WriteLine(result);␊

How to configure A .unibeautify.json file would look like the following:

{
  "C#": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "never",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: never
===================================================================
--- never   Original
+++ never   Beautified
@@ -1,5 +1,6 @@
-int·x·=·20,·y·=·10;␊
+int·x·=·20,␊
+y·=·10;␊
 ␊
-var·result·=·x·>·y·?·x·:·y;␊
+var·result·=·x·>·y·?·x:·y;␊
 ␊
 Console.WriteLine(result);␊

Add EJS Example

No example found. Please submit a Pull Request!

Edit JSX Example

🚧 Original Code

const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊

🔧 "always"

Using Pretty Diff beautifier:

const·val1·=·a␊
··?·"yes"␊
··:·"no";␊
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "JSX": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always
===================================================================
--- always  Original
+++ always  Beautified
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "always-multiline"

Using Pretty Diff beautifier:

const·val1·=·a␊
··?·"yes"␊
··:·"no";␊
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "JSX": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always-multiline",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always-multiline
===================================================================
--- always-multiline    Original
+++ always-multiline    Beautified
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "never"

Using Pretty Diff beautifier:

const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "JSX": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "never",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: never
===================================================================
--- never   Original
+++ never   Beautified
@@ -1,2 +1,2 @@
 const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊

Edit Java Example

🚧 Original Code

String·val1·=·a·!=·null·?·"yes"·:·"no";␊
String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe";␊

🔧 "always"

Using Pretty Diff beautifier:

String·val1·=·a·!=·null␊
··?·"yes"␊
··:·"no";␊
String·val2·=·a·!=·null␊
··?·(␊
····b·!=·null␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "Java": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always
===================================================================
--- always  Original
+++ always  Beautified
@@ -1,2 +1,9 @@
-String·val1·=·a·!=·null·?·"yes"·:·"no";␊
-String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe";␊
+String·val1·=·a·!=·null␊
+··?·"yes"␊
+··:·"no";␊
+String·val2·=·a·!=·null␊
+··?·(␊
+····b·!=·null␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "always-multiline"

Using Pretty Diff beautifier:

String·val1·=·a·!=·null␊
··?·"yes"␊
··:·"no";␊
String·val2·=·a·!=·null␊
··?·(␊
····b·!=·null␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "Java": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always-multiline",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always-multiline
===================================================================
--- always-multiline    Original
+++ always-multiline    Beautified
@@ -1,2 +1,9 @@
-String·val1·=·a·!=·null·?·"yes"·:·"no";␊
-String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe";␊
+String·val1·=·a·!=·null␊
+··?·"yes"␊
+··:·"no";␊
+String·val2·=·a·!=·null␊
+··?·(␊
+····b·!=·null␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "never"

Using Pretty Diff beautifier:

String·val1·=·a·!=·null·?·"yes"·:·"no";␊
String·val2·=·a·!=·null·?·(b·!=·null·?·"yes"·:·"no")·:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "Java": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "never",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: never
===================================================================
--- never   Original
+++ never   Beautified
@@ -1,2 +1,2 @@
 String·val1·=·a·!=·null·?·"yes"·:·"no";␊
-String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe";␊
+String·val2·=·a·!=·null·?·(b·!=·null·?·"yes"·:·"no")·:·"maybe";␊

Edit JavaScript Example

🚧 Original Code

const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊

🔧 "always"

Using Pretty Diff beautifier:

const·val1·=·a␊
··?·"yes"␊
··:·"no";␊
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "JavaScript": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always
===================================================================
--- always  Original
+++ always  Beautified
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "always-multiline"

Using Pretty Diff beautifier:

const·val1·=·a␊
··?·"yes"␊
··:·"no";␊
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "JavaScript": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always-multiline",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always-multiline
===================================================================
--- always-multiline    Original
+++ always-multiline    Beautified
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "never"

Using Pretty Diff beautifier:

const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "JavaScript": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "never",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: never
===================================================================
--- never   Original
+++ never   Beautified
@@ -1,2 +1,2 @@
 const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊

Add Riot Example

No example found. Please submit a Pull Request!

Add Swig Example

No example found. Please submit a Pull Request!

Add Twig Example

No example found. Please submit a Pull Request!

Edit TypeScript Example

🚧 Original Code

const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊

🔧 "always"

Using Pretty Diff beautifier:

const·val1·=·a␊
··?·"yes"␊
··:·"no";␊
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "TypeScript": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always
===================================================================
--- always  Original
+++ always  Beautified
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "always-multiline"

Using Pretty Diff beautifier:

const·val1·=·a␊
··?·"yes"␊
··:·"no";␊
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "TypeScript": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "always-multiline",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: always-multiline
===================================================================
--- always-multiline    Original
+++ always-multiline    Beautified
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊

🔧 "never"

Using Pretty Diff beautifier:

const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊

How to configure A .unibeautify.json file would look like the following:

{
  "TypeScript": {
    "indent_size": 2,
    "indent_char": " ",
    "multiline_ternary": "never",
    "beautifiers": [
      "Pretty Diff"
    ]
  }
}

Difference from original

Index: never
===================================================================
--- never   Original
+++ never   Beautified
@@ -1,2 +1,2 @@
 const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊

← Max Preserve NewlinesNewline Before Tags →
  • Support
  • Examples
Unibeautify
Docs
Getting StartedCLIConfigurationOptions
Community
User ShowcaseStack Overflow@Unibeautify on TwitterFollow Unibeautify on Twitter
More
GitHubStar Unibeautify on GitHubCode coverage of UnibeautifyCode coverage of Unibeautify
© 2020 Glavin Wiechert
Credits