Code Formatter · Beautifier (HTML, CSS, JS, PHP, Java, Kotlin, Python, SQL…)
Tidy HTML, CSS, JS, JSON, PHP, Java, Kotlin, Shell, Python, SQL, XML and YAML with tabs or spaces (2, 4 or 8), then copy it or export it as colored HTML. Your code is never sent to the server.
"Copy as HTML" gives a <pre><code> fragment with inline-style colors, so it keeps its colors when pasted into a blog or document.
Color preview
Your code is processed in this browser only and never sent to the server. The rule is to change only whitespace, but double-check important code after formatting.
How it works
- HTML, CSS, JS and JSON use the open-source js-beautify (MIT); PHP, Java, Kotlin, Shell, Python, SQL, XML and YAML use formatters written for this site.
- The formatters we wrote never change strings, comments, numbers or identifiers, only the whitespace and line breaks between tokens. Formatting twice gives the same result (idempotent).
- They are tuned for expanding code squeezed onto one line. They are not Prettier-style tools that re-flow code to a line length.
- Choosing Tab uses tab characters, choosing spaces uses that many spaces. Saving as a file adds a fitting extension (.php .kt .sh …).
FAQ
Is my code sent to a server?
No. Everything is formatted in your browser, so code that contains passwords or keys is safe to paste.
Why does Python not get restructured?
Indentation is syntax in Python, so moving or joining lines would change what the program does. Only tab ↔ space conversion and whitespace cleanup are done.
My code broke after formatting.
The rule is never to change anything inside strings or comments, but rare syntax can trip it up. Keep your original and compare, and please report the code that caused it.
What is "Copy as HTML" for?
For pasting colored code into places without code highlighting, such as blogs, wikis and email. The styles are inside the tags, so no extra CSS is needed.
How to use this tool
Use it to make messy, badly indented code readable. Format HTML, CSS, JavaScript, JSON, PHP, Java, Kotlin, Shell, Python, SQL, XML and YAML with tabs or 2, 4 or 8 spaces, then copy it or export syntax-highlighted HTML. Code is not sent to a server.
Frequently asked questions
Which languages can it format?
HTML, CSS, JavaScript, JSON, PHP, Java, Kotlin, Shell, Python, SQL, XML and YAML.
Can I choose the indentation?
Yes: tabs or 2, 4 or 8 spaces.
Is my code sent to a server?
No. Code is formatted in your browser and not sent to a server.
Related tools
See all toolsDeveloper Tools
Forty everyday developer helpers in one place (including TOTP, semver, bit operations, .env/INI/TOML conversion, JSON Schema validation, docker run → compose, .gitignore, OG tags and ASCII/ANSI tables) (now with subnet/CIDR, chmod, an HTTP/MIME/port reference, robots/sitemap and dummy data): URL, Base64, HTML and Unicode encoding, JSON formatting, CSV and type generation, Unix time, JWT decoder, hashes, UUIDs, regex, text diff, number bases, cron, certificate/CSR and mail header readers, business registration number checks, and a table converter.
Code Minifier
Remove comments and unnecessary whitespace from HTML, CSS, JS and JSON to cut file size. Paste code or open a file (drag and drop works), then copy the result or download a .min file. Your code is never sent to a server.
JSON, XML & YAML Parser
Paste or open a JSON, XML or YAML file to validate it (with the exact line and column of any error), browse it as a collapsible tree, search values and keys, look values up by path, pretty-print or minify it, and convert between formats. Everything runs in your browser — your input and files are never sent to a server.
CSS Generator
Build gradients, shadows (box/text-shadow), rounded corners (border-radius) and flex/grid layouts while watching them, then copy the CSS. Nothing is sent to a server.
Password Generator
Create a hard-to-guess password from a length and character types, or as an easy-to-remember word combination (passphrase). The result never leaves this page.
What is my IP
Check your public IP address and approximate location.