Developer tools TOOL
Code formatter
Format JavaScript, CSS, HTML, JSON and Markdown code.
Enter your text
On-device processingCode formatter · How to use
Format JavaScript, CSS, HTML, JSON and Markdown code.
Example
Paste const tools=["PDF","image"]; and select JavaScript to format indentation.
Things to know
Select JavaScript, CSS, HTML, JSON or Markdown to match the input. Code is not executed.
Output options
Your files and results are never sent to a server. Everything is processed in this browser.
How to format messy code so it is easy to read
Use it to read a minified script or a stylesheet someone sent you, or to clean up a snippet without opening an editor. Indentation becomes two spaces, and quotes and semicolons are made consistent.
When to use this tool
- Expand minified single-line JavaScript
- Clean up CSS or HTML with mixed indentation
- Tidy a snippet before pasting it into docs or chat
- Normalize Markdown lists and tables
Step-by-step instructions
- Paste the code you want to format.
- Under Code language, choose JavaScript, CSS, HTML, JSON or Markdown.
- Choose Convert. If an error appears, check the language and the code syntax.
- Copy the result or download it with the matching extension (.js, .css, .html, .json or .md).
Frequently asked questions
Which style rules are applied?
Prettier defaults are used: two-space indentation, double quotes for strings and semicolons at the end of statements. There are no options to change indent width or quote style.
Can it format code with syntax errors?
No. The code is parsed and printed again, so an unclosed bracket or similar error stops formatting and shows a message. Picking the wrong language causes the same error, so check that setting first.
How is JSON here different from the JSON formatter?
With JSON selected here, comments and trailing commas are tolerated: comments are kept and trailing commas removed. For strict standard JSON validation or minifying, use the JSON formatter and validator.