HTML / CSS Dev Tools

JavaScript formatter

Format, inspect and minify in one editor, with the original and undo history available.

JavaScript formatter

Current content

Format and Minify process the current content. Check Syntax only updates feedback. Changing syntax or style never rewrites code until you choose an action.

Ctrl/Cmd+Enter · Ctrl/Cmd+Z

Paste code or load an example.

0 UTF-16 units

Formatting options
View original

Initial input: up to 1,000,000 UTF-16 units. Output and further processing of generated documents: up to 4,000,000 units. Your code stays in this browser tab; this tool does not upload it. Undo history stays in this tab and is bounded for large documents.

A JavaScript formatter helps when a pasted snippet is hard to review or uses a different house style. Format and edit JS, JSX, TS or TSX in one editor, view the retained original, and undo or redo changes.

This JavaScript formatter parses code before printing it, so template strings, JSX and type annotations are handled as syntax rather than by replacing spaces. It reports the first parse error instead of guessing a repair. A JavaScript beautifier is useful for quick review, but this Prettier online view still follows only the options shown here.

Why use this JavaScript formatter?

Keep working on the current code, with the original and undo history available at every step.

One workspace for four syntaxes

Switch among JS, JSX, TS and TSX before formatting. A TSX component keeps its type annotations and JSX structure; it is never silently treated as executable JavaScript.

Four code syntax cards leading into one readable output panel

See exactly which style changed

The JavaScript formatter applies indentation, quotes, semicolons, line width and trailing commas only when you choose Format. Checking and changing options leave the current code intact; undo changes or restore the original when needed.

Original and formatted code panels showing differences in indentation and punctuation

Three details that prevent a wrong result

01

Choose the parser first

Select JS, JSX, TS or TSX before pasting a mixed syntax snippet. TypeScript generics and JSX angle brackets need the appropriate parser.

  • The example button loads a valid snippet for the current mode.
02

Tune the visible style

Format and Minify process the current content. Check Syntax only updates feedback. Changing syntax or style never rewrites code until you choose an action.

  • Ctrl/Cmd+Enter · Format
03

Read the result state

Review the current code, then copy or download it. Syntax errors include line and column details; use Undo or open the original to review earlier content.

  • Check Syntax does not claim to run TypeScript type checking.

What the code engine actually handles

Four parser modes

Format ordinary JavaScript, JSX markup, TypeScript annotations and TSX components using the matching Prettier parser.

Style controls

Indentation, quotes, semicolons, line width and trailing commas affect the next Format action. Minify uses separate Terser rules.

Check and minify

Check syntax separately, or minify plain JavaScript with Terser. The minified output is downloadable as a .min.js file.

Parser and output boundaries

Syntax is not type correctness
A successful parse only shows that the selected grammar accepts the snippet. No project tsconfig, dependencies or ESLint rules are loaded.
Minify accepts JavaScript only
JSX, TS and TSX must be transpiled by your own build chain first; the minify action is disabled in those modes.
Invalid code stays invalid
An unmatched bracket or unfinished string produces a line and column error. The tool does not invent missing code or execute the snippet.
No project configuration
The browser formatter uses only options shown here. It does not read .prettierrc files, plugins or ignore rules from your repository.

JavaScript formatter questions

How do I format TypeScript or JSX with the JS formatter?

Choose TypeScript or TSX for typed code and JSX for JSX without types. The JavaScript formatter uses the selected parser; it never removes TS types or compiles JSX.

Which style options can I control in the JS formatter?

You can control indentation, tabs, single or double quotes, semicolons, line width and trailing commas. These apply to formatting, not to the separate JS minifier.

Can I minify TypeScript or JSX as-is?

No. Terser accepts plain JavaScript here. Transpile TS, TSX or JSX in your project first, then paste the resulting JS in JavaScript mode.

Why does Format fail with a parse error?

The selected parser found invalid or incomplete syntax. Check the shown line and column, and confirm that the syntax mode matches the snippet.

Is my code sent to your servers?

The snippet is processed in your browser tab. It is not uploaded by this tool or placed into the URL.

Not answered?

Format code with the JavaScript formatter

Paste code, choose its syntax, then format and minify in one editor before exporting the current content.

Processed locally in your browser.