Skip to content

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.