Code Formatter
Beautify, minify and validate code online in your browser.
Format, beautify and minify HTML, CSS, JavaScript, JSON, XML, SQL and YAML in seconds. This free online code formatter also validates and repairs JSON, converts JSON to YAML, XML or CSV, and formats SQL in 19 dialects. Everything runs in your browser, so your code is never uploaded and you do not need to sign up.
No sign-up, no hidden fees
Code stays on your device
HTML, CSS, JS, JSON & more
Repair fixes comments, trailing commas, single quotes, unquoted keys, missing commas and Python or JavaScript values like None and undefined. Big numbers are kept exactly as written.
YAML output is rebuilt from the data, so comments aren’t kept. YAML also forbids tabs, so 2 spaces are used when you pick Tab.
Tip: press Ctrl + Enter inside the input box to beautify. You can also drop a file onto the input.
Private by design: your code is formatted in your browser and never uploaded. Protected by Cloudflare Turnstile.
Why Use the Code Formatter?
- Beautify and minify 7 languages: HTML, CSS, JavaScript, JSON, XML, SQL and YAML
- Validate JSON, CSS, XML and YAML before you deploy or share them
- Repair broken JSON: comments, trailing commas, single quotes and unquoted keys
- Convert JSON to YAML, XML or CSV, and XML or YAML back to JSON
- Format SQL in 19 dialects, including MySQL, PostgreSQL, SQL Server, Oracle and BigQuery
- Private and free: code is processed in your browser, never uploaded, no sign-up
Which Code Tool Should I Use?
HTML Beautifier
HTML Minifier
CSS Beautifier
CSS Minifier
JSON Formatter
JSON Validator and Repair
JSON to CSV Converter
JSON to YAML Converter
XML Formatter
XML Validator
SQL Formatter
JavaScript Beautifier
YAML Formatter and Validator
Code Formatter Features by Language
| Language | Beautify | Minify | Validate | Convert to |
|---|---|---|---|---|
| HTML | Yes, with line wrapping and attribute options | Yes, with comment removal | — | — |
| CSS | Yes, one selector per line | Yes, with comment removal | Yes | — |
| JavaScript | Yes, with brace style options | Yes, with name shortening | — | — |
| JSON | Yes, as code or tree view | Yes | Yes, with auto repair | YAML, XML, CSV |
| XML | Yes, with attribute options | Yes, with comment removal | Yes | JSON |
| SQL | Yes, 19 dialects | Yes, with comment removal | — | — |
| YAML | Yes, with quote style options | — | Yes | JSON |
How to Use the Code Formatter
Add your code
Paste code, click Upload, drop a file onto the input, or click Sample to try it.
Pick a language
Choose HTML, CSS, JSON, XML, SQL, JavaScript or YAML from the tabs.
Choose your settings
Set indentation, line wrapping, SQL dialect, keyword case and other options.
Format and copy
Click Beautify, Minify, Validate or Convert, then copy or download the result.
Frequently Asked Questions
Is this code formatter free to use?
Yes. The TeaSoft Code Formatter is completely free. There is no sign-up, no subscription and no watermark or ads in your output. You can beautify, minify, validate and convert code as often as you need.
Is my code uploaded to your server?
No. All formatting, minifying, validation and conversion happen inside your browser. Your code never leaves your device, so the tool is safe to use with private projects and work code.
Which languages does the code formatter support?
It supports HTML, CSS, JavaScript, JSON, XML, SQL and YAML. Each language has its own tab with settings for indentation, line wrapping, layout and minification.
How do I format JSON online?
Open the JSON tab, paste your JSON or upload a .json file, and click Beautify JSON. The result appears as neatly indented code or as an expandable tree view that you can copy or download.
Can the tool fix invalid JSON?
Yes. Turn on Repair common mistakes and the formatter fixes comments, trailing commas, single quotes, unquoted keys, missing commas and Python or JavaScript values like None and undefined. Big numbers are kept exactly as written.
What is the difference between beautify and minify?
Beautify adds indentation and line breaks so code is easy to read, review and debug. Minify removes spaces, line breaks and, optionally, comments to make the file as small as possible so pages load faster.
Which SQL dialects are supported?
The SQL formatter supports 19 dialects: Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery, Snowflake, Amazon Redshift, Spark SQL, Trino / Presto, IBM Db2, Hive, TiDB, DuckDB, ClickHouse, SingleStoreDB and Couchbase N1QL.
Can I change SQL keywords to uppercase?
Yes. Under Keyword case, choose UPPERCASE, lowercase or Keep as written. You can also pick a standard or tabular layout, place AND / OR at the start or end of a line, and set blank lines between queries.
Can I convert JSON to YAML, XML or CSV?
Yes. In the JSON tab, click JSON → YAML, JSON → XML or JSON → CSV. The XML and YAML tabs also have a Convert to JSON button, so you can move data in both directions.
Does the YAML formatter keep comments?
No. YAML output is rebuilt from the data, so comments are not kept. YAML also does not allow tabs for indentation, so 2 spaces are used when you choose Tab.
Can I choose 2 spaces, 4 spaces or tabs?
Yes. Every language has an Indentation setting with 2 spaces, 4 spaces or Tab, plus an option to end the file with a new line so it matches your editor and linter.
Does minifying JavaScript change how my code works?
Minifying removes whitespace and comments, and the Shorten names option renames variables to save more space. The code should work the same way, but always test minified JavaScript before you deploy it.
Can I upload a file instead of pasting code?
Yes. Click Upload or drop a file onto the input box. After formatting, click Copy, Download to save the result, or Use as input to keep working on the output.
Is there a keyboard shortcut to format code?
Yes. Press Ctrl + Enter inside the input box to beautify your code instantly without reaching for the mouse.
Does it work on mobile, tablet and Mac?
Yes. The code formatter works in Chrome, Safari, Edge and Firefox on Windows, Mac, Linux, Android and iPhone. There is nothing to install.
About the Code Formatter
The TeaSoft Code Formatter is a free online tool that beautifies, minifies and validates code in seven languages: HTML, CSS, JavaScript, JSON, XML, SQL and YAML. It also repairs broken JSON, converts data between JSON, YAML, XML and CSV, and formats SQL queries in 19 database dialects, all from one page.
It is useful for front-end developers cleaning up minified HTML, CSS and JavaScript, API and backend developers who need readable JSON responses, data analysts and DBAs reviewing long SQL queries, DevOps engineers checking YAML config files, SEO specialists reading XML sitemaps, and students learning to write clean, well-indented code.
The tool is organised into seven language tabs. HTML, CSS and JavaScript beautify or minify front-end code. JSON formats, validates, repairs and converts JSON to YAML, XML or CSV. XML formats and checks that markup is well-formed. SQL formats queries with your choice of dialect, keyword case and layout. YAML formats and validates configuration files. Every tab lets you set indentation to 2 spaces, 4 spaces or tabs.
Because the code formatter runs completely in your browser, your code is never uploaded to a server. This keeps API keys, client projects and work code private, gives you instant results even on large files, and means there is nothing to install and no account to create.
Related Code Formatter
Clean up and beautify messy HTML code online for free.
Beautify minified or messy CSS into clean, readable stylesheets.
Format, validate and beautify JSON data online instantly.
Format, beautify and validate XML online with proper indentation.
Format long SQL queries into clean, readable code online.
Beautify minified or messy JavaScript code online in one click.
Format and validate YAML files online with clean, correct indentation.