PocketPlay
中文

Code Formatter

Format or minify JavaScript, TypeScript, JSON, HTML, CSS, SCSS, Markdown and YAML with Prettier, right in your browser.

🔒 Runs in your browser — files never leave your deviceFree · No sign-up
Language
Tab width
Print width
Style
Drop a code file here
or click to choose — .js .ts .jsx .tsx .json .html .css .scss .less .md .yml

Input

Output

How to format code

  1. Pick the language, or drop a file in — the language is set from its extension and the code is loaded for you.
  2. Set tab width, print width, semicolons and quote style, then press Format. Prettier re-prints the code from its syntax tree, so the result is the same every time.
  3. Copy the result or download it with the right file extension. Minify strips whitespace instead, for JavaScript, CSS, HTML and JSON.

FAQ

Is my code uploaded to a server?

No. Prettier's browser build is downloaded from a CDN the first time you format a given language, and after that everything — parsing, printing and minifying — happens in this tab. Your code never leaves the browser.

Why did formatting fail?

Prettier has to parse the file first, so a syntax error stops it and the message tells you the line and column. Check that the language matches the code — TypeScript annotations in a file set to JavaScript, or a trailing comma in strict JSON, are the usual causes.

What does Minify do to JavaScript?

It runs Terser: dead code and comments go, whitespace is removed and local variable names are shortened, while the behaviour stays the same. CSS, HTML and JSON use a lighter whitespace-only pass that leaves strings and comments inside them intact.