About JavaScript Formatter
Make messy JavaScript easy to read. Paste your code, press Format, and get it back with tidy indentation, consistent quotes and sensible line breaks. It understands modern JavaScript, JSX and TypeScript, and points to the line and column of any syntax error. The formatting is done in your browser, and your code is never uploaded.
How to use JavaScript Formatter
- Paste your code, press Open file, or press Sample.
- Choose JavaScript or TypeScript, the indentation, line width and whether to use semicolons, single quotes and trailing commas.
- Press Format.
- Press Copy result or Download.
Tips and good to know
- Choose TypeScript for files with type annotations, interfaces or generics. JavaScript mode handles JSX too.
- If you get a syntax error, the position shown is where the formatter could not continue. The real mistake is often a little earlier, such as a missing bracket or comma.
- Formatting only changes layout. It never renames or reorders your code, so the program behaves the same.
- Press Format again after changing an option. The result does not update on its own, because big files can take a moment.
- Code up to about 500,000 characters is accepted.
Frequently asked questions
Is my code uploaded?
No. The formatter runs in your browser. It is loaded the first time you open this tool, and nothing you paste is sent anywhere.
Which style does it use?
Prettier's style, one of the most widely used ways to lay out JavaScript. You can change the main choices with the options.
Why does it say there is a syntax error?
The code is not valid JavaScript, or TypeScript syntax was used while JavaScript was selected. Switch the language, or fix the line shown.
Does it fix bugs or reorder imports?
No. It only changes spacing, line breaks, quotes and commas.
Can it format JSON or HTML?
Use the JSON Formatter or HTML Formatter tools for those.
Is JavaScript Formatter free?
Yes. JavaScript Formatter is 100% free: no sign-up, no paid plan, no trial and no limit on how often you use it. It runs in your browser, and ToolzAura is paid for by ads, so every tool stays free.
Are my files uploaded?
No. This tool runs in your browser, so your input stays on your device.