Skip to content
UniKit

JavaScript formatter

Minify and pretty-print JavaScript with one lexical pipeline: strings and comments stay untouched, the indent is selectable (2/4/tab), and invalid input or unterminated quotes fail loudly instead of silently appearing to work.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Input

Result

The result can be copied directly.

Enter JavaScript code to see the formatted result

Characters: 0 · Lines: 0

What this tool does

  • Expand bundled minified code into readable multi-line structure.
  • Normalise formatting before committing so diffs show real changes only.
  • Minify back to one line to estimate the shipped size.

Example

Input

function f(){var s="a  b";return s}

Output

function f() {
  var s="a  b";
  return s
}

Indentation follows braces and semicolons; whitespace inside strings, template literals and comments is kept verbatim.

Frequently asked questions

Is whitespace inside strings collapsed?

No. A lexical scanner separates code, strings, template literals and comments so only code is re-flowed; `"a b"` keeps both spaces.

What about unterminated quotes?

It fails with `unterminated-token`: the boundary cannot be determined, and guessing would swallow the following code.

Is this a semantic formatter?

No. It re-flows on braces and semicolons without parsing an AST: structure is safe, but there is no width-based wrapping.

Which indents are supported?

2 spaces, 4 spaces and tabs.

Keywords:javascript formatterformatconverterdeveloper

Related tools