nicetool.dev logo

Code Formatter

Pick a language, paste your code and press Format or Minify. Formatters load on demand and run in your browser.

Input · 159 B
Output

Why format and minify code?

Formatting rewrites code with consistent indentation, line breaks and spacing so it is easy to read, review and diff, which helps with minified snippets, generated SQL or copied config files. Minifying does the opposite: it removes whitespace and comments (and for JavaScript also shortens local names with Terser) to reduce download size. This tool uses Prettier, the formatter most JavaScript projects already use, and sql-formatter, which knows the syntax of MySQL, PostgreSQL, SQL Server, Oracle PL/SQL, BigQuery and more.

Features

  • • 11 languages: JavaScript, TypeScript, JSON, CSS, SCSS, Less, HTML, SQL, YAML, Markdown, GraphQL
  • • 13 SQL dialects with keyword case options
  • • Minify JS (Terser), CSS, HTML, JSON and SQL with size savings
  • • Indent size or tabs, line width, quotes and semicolons
  • • Copy or download the result, with clear syntax error messages

Your code stays local

Formatting and minifying run entirely in your browser, so API keys, internal queries or proprietary code you paste are never uploaded.

Prettier + sql-formatter, 100% client-side.

How to use the Code Formatter

  1. 1

    Choose the language tab: JavaScript, TypeScript, JSON, CSS, SCSS, Less, HTML, SQL, YAML, Markdown or GraphQL. Press Sample to load an example.

  2. 2

    Paste your code into the input panel and set the options: indent size or tabs, line width, quotes and semicolons, or for SQL the dialect and keyword case.

  3. 3

    Press Format to beautify the code with Prettier or sql-formatter, or Minify to shrink JavaScript, CSS, HTML, JSON or SQL. The size saving is shown above the output.

  4. 4

    Copy the result or download it as a file. If the code has a syntax error, the message shows the line and column so you can fix it.

Practical examples

Reading minified code

A third-party script or a bundled file is one long line. Format it to see the structure and find the function you need to debug.

Cleaning up SQL from logs

ORMs log queries on a single line. Formatting with the PostgreSQL or MySQL dialect puts SELECT, JOIN and WHERE on separate lines so the query is easy to review and optimize.

Consistent style before a commit

Formatting with the same Prettier rules your project uses (2 spaces, 80 columns, double quotes) keeps diffs small when you paste code from a chat or a snippet site.

Quick minification

Minify a small script or stylesheet for an email template, a CMS field or an inline <script> tag without setting up a build tool.

Frequently asked questions

Does formatting change how my code works?+

No. Formatters only change whitespace, line breaks and, if you choose, quotes and optional semicolons. Minifying JavaScript with Terser also renames local variables, but the behavior stays the same.

Why is Minify disabled for some languages?+

Minifying YAML, Markdown, TypeScript or GraphQL is rarely useful or would change meaning (YAML depends on indentation). TypeScript is normally compiled to JavaScript first, then minified.

Which SQL dialect should I choose?+

Pick the database you use. Dialects differ in quoting, functions and keywords, for example backticks in MySQL or :: casts in PostgreSQL, and the right dialect avoids formatting errors.

Is my code sent to a server?+

No. Prettier, sql-formatter and Terser run in your browser and are loaded only when you press a button, so proprietary code and credentials stay on your device.