JS Formatter
Format and beautify JavaScript code with proper indentation.
Format JavaScript so it's readable: consistent indentation, one statement per line and tidy spacing. Paste minified or messy code, pick 2 spaces, 4 spaces or tabs, and copy or download the result. It uses js-beautify in your browser. Plain JavaScript and JSON format best; TypeScript and JSX usually work, but unusual syntax may not be laid out perfectly. Formatting doesn't rename anything, so minified variable names stay short.
Common use cases
- Read a minified script to see what it does
- Tidy code pasted from a forum or a chat
- Make inconsistent indentation consistent
- Prepare a snippet for documentation
How to use
- Paste your JavaScript, or press Try an example.
- Choose the indent.
- Copy or download the formatted code.
FAQ
Can it un-minify variable names?
No. Minifiers throw the original names away, so there's nothing to restore. Formatting makes the structure readable.
Should I use this instead of Prettier?
For a quick one-off, this is easier. For a project, set up Prettier or your editor's formatter so everyone's code is formatted the same way.
How do I make code smaller?
Use the JS minifier, which uses Terser to remove whitespace and shorten names.
Related tools
- JS MinifierMinify JavaScript code to reduce file size.
- CSS FormatterFormat and beautify CSS code with proper indentation.
- HTML FormatterBeautify HTML code with proper indentation and formatting.
- JSON Diff ToolCompare two JSON documents and highlight differences.
- JSON MinifierMinify JSON by removing whitespace and formatting.
- YAML ValidatorValidate YAML syntax and structure for configuration files.