Skip to content

Code formatter and minifier

Runs on your device

Format JavaScript, TypeScript, CSS, HTML, Markdown, YAML and GraphQL with Prettier, or minify JS and CSS, in your browser.

Mode

How to use Code formatter and minifier

  1. Paste your code; the language is detected automatically, or choose it.
  2. Pick Format or Minify, and set the indent, line width, semicolons and quotes.
  3. Copy the result; it updates as you type.

Consistent code in one paste

Code copied from a Stack Overflow answer, a minified bundle, an email, a CMS or a colleague's editor arrives in every style: tabs and spaces mixed, long lines, missing semicolons, quotes of both kinds. This tool formats it with Prettier, the opinionated formatter most JavaScript and web projects run on save, so it comes back consistent, readable and in the same style as code formatted in an editor.

It handles JavaScript, TypeScript, JSX and TSX, CSS, SCSS and Less, HTML including inline scripts and styles, Markdown, YAML, GraphQL and JSON. The language is detected from what you paste, and you can change it if the guess is wrong. Set the indent, line width, semicolons and quote style to match your project.

Minify JavaScript and CSS

Switch to Minify to shrink code for production or for pasting into a size-limited field. JavaScript is minified with Terser, the minifier used by most bundlers: it removes whitespace and comments, shortens local variable names and drops unreachable code, while keeping licence comments that start with /*! or contain @license. CSS is minified with CSSO, which also merges duplicate rules and shortens colours and values. The size before and after is shown.

Errors you can act on

If the code can't be parsed, the tool shows the parser's message with the line and column, which makes it a quick way to find a missing bracket or a stray comma. Nothing is changed until the code parses, so formatting can't silently damage broken code. Formatting never changes what the code does: only whitespace, line breaks, quotes, semicolons and wrapping.

Private and lightweight

Code often contains API keys, internal URLs and unreleased features, so it's formatted in your browser and never uploaded. The page itself loads no formatter at all: Prettier and the parser for each language download from this site the first time you use that language, then stay cached.

Questions

Is this the same as running Prettier?
Yes. It's Prettier 3, the formatter most JavaScript projects use, running in your browser with the same options, so the output matches what Prettier gives in an editor or a build.
Which languages can it minify?
JavaScript, with Terser, which also shortens variable names and removes dead code while keeping licence comments, and CSS, with CSSO, which merges rules and shortens colours and values. Other languages are formatted only.
Is my code uploaded?
No. Formatting and minifying run in your browser, and each language's parser loads from this site only when you first use it. Nothing you paste is sent or stored.