Code Beautifier Guide: JS, CSS, HTML and JSON

Code Beautifier Guide: JS, CSS, HTML and JSON

Make minified JS, CSS, HTML and JSON readable. Online beautify vs Prettier/ESLint, pre-commit hooks, and when unminify is the better verb.

27.04.2026
8 min read
Share this article:
BeautifyformattingCodeJavaScriptCSSHTMLJSONDevelopmentTutorial

Why beautify your code

Beautifying (or formatting) code means re-indenting, spacing and structuring a file so it becomes readable. It is the opposite of minification. Where an online JavaScript minifier compresses your script into a single line, a beautifier expands it back into clean, indented blocks. When you pick up a production bundle, a third-party export or a compact API payload, the code is often unreadable. An online JavaScript unminifier or a CSS, HTML, JSON, XML or SVG beautifier then becomes necessary. FastMinify has a Beautify mode for JS, CSS, JSON, HTML, XML and SVG, as well as SQL, YAML, TOML, Markdown, GraphQL, Less, SCSS and TypeScript. This guide covers online tools, editor integrations (Prettier, ESLint, EditorConfig), pre-commit hooks and the habits that stop you from wasting time on badly formatted code.

Read a minified production bundle without setting up an environment
Speed up code reviews, security audits and debugging on compacted third-party code
A consistent style across the team with Prettier, ESLint and EditorConfig
One family of online tools to beautify JS, CSS, HTML, JSON, XML and SVG
A clean cycle: beautify in development, minify in production, to ship lean code and still debug easily

Where a beautifier helps most

Debugging a production bundle

You are tracking down an error in Sentry at line 1, column 84327 of an `app.min.js` file. Without a beautifier, you cannot locate the block visually. Paste the file into a beautifier, and you get structured, navigable code that you can cross-reference with your source map.

Production error dashboard pointing to a line in a minified bundle, with a magnifier and the reconstructed source code

Before optimization

File size
1 unreadable line
Load time
Debugging impossible

After optimization

File size
Spaced, indented code
Load time
Bug located without guesswork
Common use cases

These are the situations where a beautifier saves the most time:

Reading a JSON API payload returned on a single line by a misconfigured backend
Inspecting an SVG exported from Figma or Illustrator to understand its structure
Comparing two minified versions of a file to spot real differences
Picking up a legacy project where a CMS outputs its HTML on one line
Auditing obfuscated code shared by a client or found in a repository
Beautify ≠ deobfuscation

A beautifier re-indents code but does not rename the `a`, `b`, `c` variables produced by an aggressive minifier. To go further, combine the beautifier with a source map or a renaming tool. For JavaScript, see our dedicated guide on how to unminify JavaScript for debugging.

Before/after comparison of a beautified JavaScript file

Editor workflow and pre-commit hooks

Format on Save in VS Code, JetBrains and Vim

Formatting automatically on save ends most style debates in code review. The whole team converges on the same standard with little effort.

VS Code: Prettier extension and `"editor.formatOnSave": true` in settings.json
VS Code: `"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }` to run ESLint --fix on save
JetBrains (WebStorm, PhpStorm): Settings → Tools → Actions on Save → Reformat code
Vim/Neovim: `conform.nvim` or `none-ls.nvim` with Prettier as the formatter
EditorConfig (`.editorconfig`): shared rules that every editor reads, such as indent, end of line and charset
Pre-commit hooks as a last line of defense

With Husky and lint-staged, every commit automatically beautifies the modified files. No pull request carries pure formatting noise again.

Conventions to lock down as a team

A beautifier is useless if config diverges across machines. Centralize everything in the repo:

Version `.prettierrc`, `.editorconfig` and `eslint.config.mjs` at the root
Add `.prettierignore` to exclude minified files and build folders
Document `npm run format` in the README to run the full pipeline
Block PRs in CI when `prettier --check` or `eslint` raise errors
Pair with an online CSS minifier to quickly verify production output

Beautify and minify are two sides of the same cycle

Quick definition

Beautify formats code for humans, and minify compresses it for production. Both operations are meant to keep the behavior of the code (aggressive minification options aside). JavaScript example:

Before

function add(a,b){return a+b;}const result=add(1,2);console.log(result);

After

function add(a, b) { return a + b; } const result = add(1, 2); console.log(result);
What a beautifier does (and doesn't)

A beautifier works on layout, not logic. Know where its limits are:

DOES: re-indentation, line breaks, spacing around operators
DOES NOT, by itself: sort CSS properties, JS imports or JSON keys (a plugin or a dedicated tool does that)
DEPENDS ON THE TOOL: adding or removing optional semicolons and converting quote styles (Prettier does, js-beautify does not)
DOES NOT: rename minified variables (`a` does not become `userName` again)
DOES NOT: rebuild obfuscated code (eval, string concat, packers)

Beautify with FastMinify

In the browser

Each FastMinify tool page links to the other actions for the same format (Minify, Beautify, Unminify). Processing stays entirely in your browser, with no upload to a server, which suits sensitive files and internal payloads.

FastMinify interface highlighting the Beautify button
1

Pick the tool that matches your language

Use the JavaScript beautifier for JS and the CSS beautifier online for stylesheets, and likewise for HTML, JSON, XML and SVG.

2

Paste the minified code

Paste the content into the editor on the left.

3

Select Beautify

The reformatted code appears on the right. Copy the result or download it to reuse in your IDE.

When an online tool fits

An online tool covers cases where you do not have access to your stack or a dev environment (customer support, one-shot audit, quick sharing).

JS, CSS, JSON, HTML, XML and SVG on one site, plus SQL, YAML, TOML, Markdown and more
No installation, no account, free
Your code stays in your browser and is never uploaded to a server
Minify is one link away for the trip back to production
Pairs well with an online JSON formatter for APIs and an online SVGO SVG optimizer for assets

Beautify in your editor and your scripts

Prettier, the standard for JS, CSS, HTML and JSON

Prettier is the reference tool. It installs with one command and works on almost every front-end language. Configure it in `.prettierrc` and turn on Format on Save in VS Code, so you never have to think about it again.

Configuration

// .prettierrc { "semi": true, "singleQuote": true, "trailingComma": "all", "printWidth": 100, "tabWidth": 2 }

Usage

# Install npm install --save-dev --save-exact prettier # Beautify the whole project npx prettier --write "**/*.{js,ts,css,html,json,md}" # Check without writing (CI) npx prettier --check "**/*.{js,ts,css,html,json,md}"
ESLint --fix for JavaScript and TypeScript

ESLint --fix applies the automatic fixes that its rules provide, for style and for some quality issues (unsorted imports with a plugin, for example). Combine it with Prettier via `eslint-config-prettier` to avoid conflicts.

Configuration

// eslint.config.mjs export default [ { rules: { 'indent': ['error', 2], 'quotes': ['error', 'single'], 'semi': ['error', 'always'] } } ];

Usage

# Auto-fix every file npx eslint . --fix # Combine with Prettier npx eslint . --fix && npx prettier --write .
HTML, JSON, JSON.stringify and jq

To beautify without installing Prettier, built-in or native tools do the job: `JSON.stringify(obj, null, 2)` in Node, `jq '.'` on the command line, and `html-beautify` (from js-beautify) for HTML.

Basic example

// Beautify JSON with native JavaScript const minified = '{"user":{"name":"Ada","age":36}}'; const pretty = JSON.stringify(JSON.parse(minified), null, 2); console.log(pretty);

Usage

# Beautify JSON with jq jq '.' minified.json > pretty.json # Beautify HTML with js-beautify npx js-beautify --type html input.html -o output.html # Beautify SVG with xmllint xmllint --format icon.svg > icon.pretty.svg

Beautifying each language, with concrete examples

JavaScript and TypeScript

Pull a production bundle and get readable code. If you work on minified code without a source map, also read our guide how to unminify JavaScript for debugging.

JavaScript example

function fetchUser(id){return fetch(`/api/users/${id}`).then(r=>r.json()).catch(e=>console.error(e));}

Command line

function fetchUser(id) { return fetch(`/api/users/${id}`) .then((r) => r.json()) .catch((e) => console.error(e)); }
CLI: `prettier --write "src/**/*.{js,ts}"`
Editor: Prettier + Format on Save in VS Code
CSS and preprocessors

Minified CSS strips every space and merges selectors. A beautifier brings back the structure and makes cascade audits much easier.

JavaScript example

.btn{display:inline-flex;align-items:center;padding:.5rem 1rem;border-radius:.375rem;background:#3b82f6;color:#fff}

Command line

.btn { display: inline-flex; align-items: center; padding: 0.5rem 1rem; border-radius: 0.375rem; background: #3b82f6; color: #fff; }
CLI: `prettier --write "**/*.css"` or `stylelint --fix`
Workflow: ship to prod via the online CSS minifier
JSON, HTML, XML and SVG

Declarative formats benefit massively from clean indentation. Especially true for Illustrator SVG exports and large XML sitemaps.

JSON: online JSON beautifier or `JSON.stringify(obj, null, 2)`
HTML: online HTML beautifier or `js-beautify --type html`
XML: online XML beautifier or `xmllint --format`
SVG: online SVG beautifier with the Beautify mode for Figma exports. Use optimize SVG for SVGO optimizations.
Keep a beautified development version and a minified production version side by side to compare them

Conclusion

Beautifying code is not a luxury. It is the habit that shortens debugging, makes auditing third-party code feasible and aligns your team on a shared standard. The right workflow has two parts. An online tool covers one-off cases, such as debugging a production bundle or reading a client export. An automated chain (Prettier, ESLint, EditorConfig and pre-commit hooks) covers daily projects. Send files back through a minifier when you ship, which is the other side of the same cycle. To choose between online tools and build tools, read our comparison online minifiers vs build tools.

Beautify or minify your code in your browser

For a one-off file, use the FastMinify online tools (JS, CSS, JSON, HTML, XML, SVG)
For a project, install Prettier and ESLint and turn on Format on Save
Commit `.prettierrc`, `.editorconfig` and `eslint.config.mjs` to align the team
Add Husky and lint-staged to beautify automatically on every commit
Close the loop: beautify in development, minify in production with the online JS minifier
Share this article
Share this article: