Text & Regex

JavaScript Formatter

Format, beautify, and conservatively minify JavaScript with configurable indentation.

Ctrl/Cmd+Enter to format

JavaScript input

Result

Formatted or minified JavaScript will appear here.

JavaScript is parsed and formatted locally in your browser and never executed. Input and output are not uploaded, saved to browser storage, or included in analytics events.

Your data stays private

This tool runs directly in your browser. The content you enter is processed locally and is not sent to TechFixGen servers. No account or signup is required.

JavaScript formatting guide

Parse before you print

The formatter parses your code with the Babel parser, then prints it back with consistent indentation, spacing, and line breaks. It understands modern JavaScript: optional chaining, nullish coalescing, private class fields, static blocks, top-level await, import attributes, and decorators. Paste a script and press Ctrl+Enter (Cmd+Enter on Mac) or click Format.

Choose your indentation

The Indentation control selects 2 spaces, 4 spaces, or tabs. The parser always prints with two-space units, so the formatter remaps that base indentation to your selection. Change the control and click Format again to re-render the output.

Formatting versus minifying

Format expands the parse tree into readable vertical structure while keeping your comments. Minify prints the same tree in a single compact line and drops whitespace and non-important comments. Minification is conservative: it never renames variables, rewrites strings, or alters literal values, and rejects code it cannot parse rather than guessing.

Syntax errors and locations

When the parser rejects a script, the formatter reports the message with a line and column so you can jump straight to the offending token. The parser is strict about structure, so a missing brace, a stray token, or an unbalanced bracket stops formatting rather than producing broken output.

This tool never executes code

Formatting and minifying are purely mechanical operations over the parse tree. Nothing is evaluated: no functions run, no import is fetched, and no side effect is triggered. The result of running your code can differ from what you see here.

Privacy and large scripts

Processing happens locally in the browser. JavaScript input and output are not uploaded, saved to the URL, localStorage, or sessionStorage, and are not included in analytics events. Copy writes to your clipboard only when you click it; Download saves a file your browser generates locally. Reloading the page clears the workspace.

Very large scripts use browser memory while parsing and printing. If a script is bigger than a megabyte of source, consider splitting it into modules for formatting. Unsupported syntax (for example experimental proposals the installed parser version has not enabled) is reported as a syntax error.

Frequently asked questions

Does formatting execute my code?

No. Formatting and minifying operate on the parsed syntax tree and never evaluate it. No function runs, no import is fetched, and no side effect is triggered while the formatter works.

Does formatting validate my code?

Formatting requires code that parses, so structural mistakes such as missing braces or stray tokens are reported with a line and column. It does not perform type checking, resolve imports, or catch runtime errors. Code that formats cleanly is not guaranteed to run.

Which JavaScript features are supported?

The parser supports ECMAScript in current use: optional chaining, nullish coalescing, logical assignment, numeric separators, private class fields and methods, static blocks, top-level await, import attributes, and legacy decorators. Proposals not enabled in the installed parser version are reported as syntax errors.

Is minification safe?

Minification prints the same syntax tree in one line and removes whitespace and non-important comments. It never renames variables, collapses expressions, or rewrites strings and numbers, so the printed result stays faithful to the source. Code that fails to parse is rejected instead of silently changed.

What does the error location mean?

The reported line and column point at the token where the parser stopped. The column counts characters from the start of the line, and the Jump to error button selects that position so you can inspect the surrounding source.

Is my JavaScript uploaded or saved?

No. Parsing runs locally in your browser. Source and output are not sent to a formatting service or to analytics, and are not saved in the URL, localStorage, or sessionStorage. Copy writes the output to your clipboard when clicked; Download saves a file your browser generates locally.