How to use Code Beautifier
- Paste source code or choose one supported UTF-8 source file. A selected file replaces pasted text.
- Choose the language, or select Suggest language from content/file name and check that its choice fits the source. Set indentation, preferred line width and quote preference.
- Select Format code. Compare the result with the original, then copy it or download the formatted file. Run your project checks before replacing source.
Example: Code Beautifier
Format a compact JavaScript object with two-space indentation.
Options
- Source and language
- A selected UTF-8 file takes priority over the text box. Language suggestion uses the filename or simple content patterns; choose the language explicitly if it guesses incorrectly.
- Indentation
- Use two spaces, four spaces or tabs where the selected formatter supports them.
- Line width
- Enter a whole number from 40 to 160. This is a wrapping preference, so long strings or other unbreakable content can exceed it.
- Quote preference
- Prefer single quotes affects languages that support this choice. The formatter can retain another quote style to avoid escapes; it does not convert JSON to single-quoted JavaScript.
Supported inputs and limits
- Up to 1,000,000 characters and 50,000 lines; browser jobs stop after 10 seconds.
- Prettier 3.9.9 formats JavaScript/JSX, TypeScript/TSX, JSON, CSS/SCSS, HTML, Markdown and YAML.
- Embedded code blocks stay unchanged.
- This does not compile, execute, lint or prove that code is correct.
- PHP, Python, C/C++ and Java are not supported here.
More details
Long strings can exceed the preferred line width.
The language suggestion is a heuristic that the visitor can change.
Selected UTF-8 files replace pasted code.
There is no minifier, PHP engine or compilation step.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Review formatting before saving
Formatting rewrites whitespace and may change quotes or punctuation according to the selected language. Keep the original source, compare the result and run your own tests before replacing a file.
Questions about Code Beautifier
Does this run my JavaScript?
No. The formatter parses and prints source text in a browser worker. It does not execute your program.
Why does a line exceed my width setting?
Line width is a wrapping preference. The formatter can keep a string, identifier or other unbreakable expression longer than that width.
Can I format SQL or XML?
Use the separate SQL Formatter or XML Formatter pages. Each page names the formats and checks it supports.