Zero Signup ToolsFree browser tools

Developer Tools

JavaScript Formatter

Paste minified or messy JavaScript and copy a clean, indented version. Quote, semicolon, indent, and line ending options. Runs in your browser.

JavaScript formatter and beautifier

Format options

Pick the indent, quote style, semicolon policy, and line endings. Output updates as you type.

0 chars / 0 B

Indent

Quotes

Keep each string literal's existing quote style.

Semicolons

Leave semicolons as they are in the source.

Line endings

Unix line endings (\n). Best for git, macOS, and Linux.

0 chars
Load sample

The JavaScript you paste is parsed and rendered entirely in your browser. The code never leaves your device.

Formatted output

Paste minified or dense JavaScript to beautify it. The output appears here automatically.

What gets formatted

Statements and blocks
Each statement lands on its own line. Function bodies, class bodies, if/else, for, while, switch, try/catch/finally, and do/while blocks are indented one level per nesting depth.
Object and array literals
Multi-property objects and multi-item arrays expand onto multiple lines with one entry per line. Empty {}and [] stay on one line.
Strings, regex, and templates
String literals are recognised with their quote style. Regex literals like /foo/gare kept intact and never confused with division. Template literals (including ${...}placeholders) pass through unchanged.
Comments
// line comments and /* ... */ block comments are preserved at their original position. Multi-line block comments keep their original line layout.
Modern syntax
ES classes, arrow functions, async/await, spread ..., optional chaining ?., nullish coalescing ??, numeric separators, and bigint literals are recognised.
Quote and semicolon options
Use the quote selector to rewrite single quotes to double quotes or vice versa with proper escape handling. Use the semicolon selector to insert a trailing semicolon on statement lines that are missing one.

How to use

  1. Paste minified, dense, or messy JavaScript into the input area on the left. Use the sample buttons to try a minified bundle, an IIFE, an ES class, an async/await snippet, an object literal, regex-heavy code, or template literals.
  2. Pick the indent (2 spaces, 4 spaces, or tab) that matches your project's style guide. Output updates as you type.
  3. Optionally rewrite quotes (preserve, single, or double) and insert missing semicolons. Pick LF for Unix and git or CRLF for Windows.
  4. Click Copy output to copy the pretty printed code, or use Replace with output to keep formatting and iterate further with different options.
  5. Read the parser notes panel if the input had an unterminated string, an unclosed comment, or an unfinished template literal so you know what was treated as best-effort output.

About this tool

JavaScript Formatter takes minified bundles, dense one-liner snippets from Stack Overflow, network-tab dumps, inline <script> contents, IIFEs, polyfills, webpack chunks, and modern ES code with classes, arrows, async/await, spread, destructuring, and template literals, then pretty prints them with consistent indentation, spacing, and line breaks so the structure becomes readable. The tokenizer is string-aware, regex-aware, and template-literal aware: it knows when a forward slash starts a regex literal versus when it is the division operator, which is the central source of bugs in naive JavaScript beautifiers; it handles ${...} placeholders inside template literals including nested templates and quoted strings; and it preserves both // line comments and /* ... */ block comments at their original position. The printer indents the source one level per open brace, bracket, or paren depth using either two spaces, four spaces, or a tab character; it places each statement on its own line, each property of a multi-property object literal on its own line, and each item of a multi-item array literal on its own line; it folds empty {} and [] back onto a single line; it keeps for-loop headers like for (let i = 0; i < n; i++) on a single line by recognizing that semicolons inside that paren do not terminate a statement; it keeps } else, } catch, } finally, and } while on the same line as the closing brace so do/while and if/else chains read naturally; and it preserves a single blank line between top-level declarations when the source had one. The optional quote selector rewrites double-quoted string literals to single quotes (or single to double) with proper handling of embedded escapes, the optional semicolon selector inserts a trailing semicolon at the end of statement lines that are missing one, and the line-ending selector emits LF (\n) for Unix, macOS, Linux, and git diffs or CRLF (\r\n) for Windows. Useful for developers reading a minified bundle from the Network tab, frontend engineers triaging a vendor snippet, support teams trying to make sense of an inline <script> pasted into a bug report, anyone learning JavaScript who copied an obfuscated example from a blog post, and reviewers who want to diff a compressed file against a readable expansion. The companion tool, JS Minifier, does the inverse and squashes formatted JavaScript back to a compact bundle. Everything runs locally; the JavaScript you paste here, including string contents, regex patterns, and embedded credentials in URLs or headers, never leaves your device.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools