Code Beautifier

Format and beautify JavaScript, CSS and HTML code

Input Code

Drag and drop your file here

or click to enter code

Supported: js, css, html, php

Formatted Code
Waiting for input...

About This Tool

Paste JavaScript, CSS or HTML that has been minified or mangled and get it back with proper indentation and line breaks. The language is detected from the code, and you can also pick it by hand. No installation, no sign-up.

Handy when you have pulled a file out of a theme or plugin and it is all on one line, when code copied from somewhere arrived with broken indentation, or when you have to hunt for a bug in someone else's code and first need to be able to read it.

Set the indent to spaces or tabs at a width of 2, 4 or 8, drag in a file or paste the code, and read the line and character counts under the output. Copy the result or save it as a file. The code you paste never leaves your device.

Frequently Asked Questions

How do I format my code?
Paste it into the input box or drag a file onto it, then press the beautify button. On auto the language is read from the code itself and the one that was formatted is named above the output.
How do I change the indentation?
Use the bar at the top to set the type to Space or Tab and the width to 2, 4 or 8. The default is 4 spaces.
Which files does it accept?
The js, css, html and htm extensions, plus php files, which are formatted as HTML. Other extensions get an unsupported message; in that case copy the file contents into the input box instead.
What is the downloaded file called?
Depending on the detected language, beautified.js, beautified.css or beautified.html. Rename it however you like afterwards.
It says there was a formatting error, what is wrong?
The code is not structurally valid, usually an unclosed brace or bracket. If you copied only a fragment from the middle of a file, take a larger piece so the blocks open and close.
Does it fully restore minified code?
Indentation, line breaks and spacing come back and the code becomes readable, but variable names that were shortened and comments that were stripped during minification do not return. It is enough for reading and debugging.
Does the code behave differently afterwards?
No. Only whitespace, indentation and line breaks change; nothing is added to or removed from the logic.
Tabs or spaces?
Follow your project convention. If you work with a team, match the rest of the project files; otherwise 2 or 4 spaces is the most common choice.
What does the Sample button do?
It loads ready-made code into the input so you can see the shape of the output without bringing in your own.
What are the line and character counts for?
They show how long the output is, which is useful for comparing against the minified version and estimating file size.
Do you have a tool for minifying code?
Yes. The code compressor does the opposite of this and produces the slimmed-down version for your site.
Does it work for JSON?
For JSON, use the JSON formatter, which also pins syntax errors to a line number.
Is the code I paste stored anywhere?
No. Everything runs on your own device and neither the input nor the output is stored by us.
Was this tool helpful?
4.6out of 5
Thanks for your feedback!

Related tools

Home