Skip to content
Swizztool

JavaScript Formatter

Format JavaScript, TypeScript, and JSX with Prettier in your browser. Choose 2 spaces, 4 spaces, or tabs, and whether to use semicolons and single quotes.

Indent

Your text 376 chars · 1 line

Result

How to use JavaScript Formatter

  1. Paste JavaScript, TypeScript, JSX, or minified code.
  2. Choose indentation, semicolons, and quote style.
  3. The formatted code updates as you type; syntax errors are shown with their position.
  4. Copy or download the formatted code.

About JavaScript Formatter

Format messy or minified JavaScript, TypeScript, and JSX with Prettier, the formatter most teams use. Choose 2 spaces, 4 spaces, or tabs, and whether to use semicolons and single quotes. Syntax errors are reported with their position.

Related tools: JSON Formatter & Validator, Base64 Encoder / Decoder, URL Encoder / Decoder, JWT Decoder

Why Prettier

Prettier reformats code from scratch based on its structure, so the output is consistent no matter how the input was written. It is the same engine used in VS Code and most JavaScript projects, which means code formatted here matches what your editor would produce.

Because it parses the code first, Prettier also catches syntax errors. If the code cannot be parsed, you get the error message and line instead of half-formatted output.

Reading minified code

Formatting adds line breaks and indentation to minified bundles so you can follow the logic. It cannot restore original variable names; minifiers rename them to single letters and that information is gone.

Prettier loads the first time you use the tool, which can take a second on a slow connection. After that, formatting is instant.

Common uses

Reading minified scripts
Make a one-line bundle or snippet readable for debugging.
Cleaning pasted code
Fix indentation in code copied from chat, docs, or Stack Overflow.
Matching team style
Format a snippet the same way your project's Prettier setup would.
Checking syntax
Find the line where a missing bracket or comma breaks parsing.

Questions about JavaScript Formatter

Can this unpack minified code?
Yes, it splits statements, indents nested blocks, functions, and objects for readable inspection.
Does it support TypeScript?
Yes. TypeScript types, interfaces, and JSX are all supported.
Can it format CSS or HTML?
Not this tool. Use the CSS and HTML minifiers for those files.
Is my code uploaded?
No. Prettier runs in your browser.
Can I format JSON with this tool?
It can, but the JSON Formatter gives clearer error messages and a minify option for JSON.

Comments

Questions, ideas, or a bug in JavaScript Formatter? Let us know.