Format JavaScript Online
Clean up JavaScript or TypeScript that has lost its indentation. Paste the code, set your tab width, and get readable, consistently formatted output.
Code Formatter
LOCAL · Browser-OnlyBeautify and format JavaScript, CSS, HTML, and more
Quick Start
- 1Paste your JavaScript or TypeScript into the editor
- 2Select the language and tab width
- 3Click Format to beautify the code
- 4Copy or download the formatted output
What This Tool Does
The file is parsed and then printed again from scratch, so the formatting you started with does not matter. Minified code, code with mixed tabs and spaces, and code that has passed through three editors all come out looking identical.
The controls cover the decisions that usually cause arguments in a codebase: indent width at two, four or eight spaces or tabs, print width at 60, 80, 100 or 120 columns, semicolons on or off, single or double quotes, trailing commas set to all, ES5 or none, arrow parentheses always or only when needed, and bracket spacing.
A diff view sits next to the formatted output and marks the lines that actually changed, with a count of additions and removals and the byte difference. That is the quickest way to confirm a reformat did not touch anything you cared about.
Limits Worth Knowing
- It will not fix a syntax error. A file that does not parse stops with the line, the column and a snippet showing the offending code.
- The line-by-line diff is skipped once either side goes past roughly 3000 lines, and the view falls back to the formatted output on its own.
- Pasting a very large file does not format it automatically. Press Format once the text is in.
- Formatting changes layout only. Nothing is renamed, removed or reordered.
- TypeScript and JSX are handled by selecting the matching language rather than relying on detection alone.
Common Questions
Can it minify my JavaScript too?
Will it change my quotes?
What happens to my comments?
More Format Tools
All formatters →Format & Beautify JSON Online
Paste minified or messy JSON and format it with proper indentation. Free online JSON formatter with validation.
Format SQL Queries Online
Beautify and indent SQL queries for better readability. Free online SQL formatter supporting MySQL, PostgreSQL, and more.
Format & Beautify XML Online
Paste XML data and format it with proper indentation and syntax highlighting. Free online XML formatter and validator.
Format & Beautify CSS Online
Paste minified or messy CSS and format it with proper indentation. Free online CSS formatter and beautifier.
Format & Beautify Code Online
Format and beautify JavaScript, Python, PHP, Java, and C++ code. Free online code formatter with syntax highlighting.
Format JSON Online Free
Format and beautify JSON online for free with syntax highlighting. Paste raw or minified JSON and get clean indented output, no signup.
Looking for FAQs and advanced options? Visit the full Code Formatter page →