How to use: HTML, CSS & JavaScript formatter
- Choose HTML, CSS or JavaScript.
- Paste the code.
- Format it with Prettier and copy or download it.
What it accepts and what you get
- Input
- Code up to 1 million characters.
- Output
- Consistently formatted code.
- Where your data is processed
- Your data is processed in your browser and is not sent to our servers.
Limitations and notes
- The code is never run: it is only parsed and printed again.
- Code with syntax errors shows the error instead of a result.
Frequently asked questions
How do I format HTML, CSS or JavaScript code?
Choose the language, paste the code and get the result formatted with Prettier, which you can copy or download.
Is my code executed when I format it?
Never: it is only parsed and rewritten. If it has syntax errors, the error is shown instead of a result.
What is Prettier?
It is a widely used code formatter that rewrites code in a consistent style: indentation, quotes and line breaks. It changes the look, not what the code does.
Why do I get an error instead of formatted code?
Because the code has a syntax error, such as an unclosed bracket or brace. Prettier cannot format what it does not understand: fix the line the message points to.
When to use it
- When you inherit minified or badly indented HTML, CSS or JavaScript.
- To unify the style before sharing a snippet.
- When you want to see what a piece of minified CSS or JavaScript does.
Examples
- CSS on one line
- Paste it, choose CSS and get each rule on its own lines with indentation.
- JavaScript with an error
- If there is a syntax error, the tool shows it instead of a result.
- Minified JavaScript
- You paste code squashed into one line and get a version with indentation and one statement per line.
Common mistakes
- Expecting it to run or check the logic: it is only parsed and printed again.
- Choosing the wrong language: the HTML formatter is no use for CSS.
- Pasting code from another language, such as PHP or Python: only HTML, CSS and JavaScript are formatted.

