# Code Formatter — Format & Minify

Paste code to format it with the language auto-detected. Choose indent, line width, semicolons, quotes and trailing commas; JavaScript, CSS and HTML can also be minified with before/after size and reduction. Your code never leaves the browser.

- URL: https://tools.itlibra.com/en/code-formatter
- On-device・No upload
- Last updated: 2026-11-27

## How to use

1. Choose Format or Minify and paste code into the input pane (you can also open or drop a file; Shift\_JIS files are read too).
2. Leave the language on Auto-detect, which uses the file extension and the content. Pick one manually if it guesses wrong.
3. When formatting, set indent (2/4 spaces or tab), line width, quotes, semicolons and trailing commas. When minifying, choose how comments are handled, whether to shorten local variable names, and whether to minify the contents of \<style\> and \<script\> in HTML.
4. The result appears on the right. A syntax error shows the line, column and an excerpt, and “Go to error” selects that spot in the input.
5. Copy or download the result. The extension follows your file, and minified files get .min.

## Use cases

- Make a one-line snippet from a log or bundle readable for review
- Bring files with mixed styles to one set of rules (indent, quotes, semicolons)
- Minify CSS, JavaScript or HTML for delivery while watching the size reduction
- Check what Prettier would do without installing anything
- Format or minify source you cannot upload anywhere

## What it does

### Seven languages through Prettier

JavaScript (with JSX), TypeScript (with TSX), CSS, SCSS, Less, HTML and Vue (.vue) are formatted by Prettier 3.9.10. Formatting the output again changes nothing (idempotent). The engine for each language is loaded only when needed, so the first view stays light.

### Language detected from extension and content

The file extension (.ts, .tsx, .scss, .vue …) wins; for pasted text the content (type annotations, interfaces, $variables, @mixin, HTML tags …) picks the candidates. If the first guess fails to parse, the next one is tried (for example TS after JS).

### Errors with line and column; input is never cleared

Syntax errors are reported with line, column and an excerpt, and you can jump to the spot in the input. The engine’s message is shown on screen only and is never sent to notifications or logs.

### Minifying that keeps the meaning

JavaScript goes through Terser (top-level names are not renamed). CSS keeps strings, url(), escapes and /\*! comments byte for byte and only drops whitespace and comments. HTML keeps the contents of \<pre\>, \<textarea\> and elements with an inline white-space rule, attribute values, &nbsp;, and one space between inline elements.

### A conservative HTML default

By default only whitespace that does not render is removed (in \<head\>, around table structure and so on). Removing whitespace around block elements such as \<div\> and \<p\> is an opt-in, because it can change the layout if your CSS changes \`display\`.

### Reduction shown; Unicode-safe

Before/after size and the reduction are shown, and you are told when minifying makes the file larger (for example already-minified code). Japanese and other non-ASCII identifiers, comments and strings are left as they are.


## Supported formats

### Input

- .js
- .jsx
- .mjs
- .cjs
- .ts
- .tsx
- .css
- .scss
- .less
- .html
- .htm
- .vue
- Pasted text
- UTF-8 / UTF-16 (BOM) / Shift\_JIS

### Output

- Formatted code (saved with the original extension)
- Minified code (.min.js / .min.css / .min.html)


## Capability matrix

| Feature | Support | Notes |
| --- | --- | --- |
| Format JavaScript, JSX, TypeScript, TSX, CSS, SCSS, Less, HTML and Vue | Supported | Prettier 3.9.10; \<script lang="ts"\> in Vue is formatted too |
| Format options (indent, width, quotes, semicolons, trailing commas) | Supported | — |
| Minify JavaScript (whitespace/comments, shorter local names) | Supported | Terser; top-level names are not renamed |
| Minify CSS | Supported | Whitespace and comments only; no rewriting of numbers, colors or selectors and no rule merging |
| Minify HTML | Partial | Only changes that keep the meaning. \<pre\> and \<textarea\> are kept; no renaming, tag omission or quote removal |
| Minify TypeScript, JSX, SCSS, Less or Vue | Not supported | It needs a compile step to strip types or syntax. Convert to JS / CSS first (formatting works) |
| Format JSON, SQL, XML, YAML or Markdown | Not supported | Use JSON Studio, SQL Studio, XML Studio, YAML / TOML Studio or Markdown Studio |
| Obfuscation | Not supported | Local names are shortened, but nothing is done to make code hard to read (such as string encryption). It cannot hide your source |
| Running code, type checking, linting, dead-code detection | Not supported | It only formats what it can parse |
| Reading config files (.prettierrc, EditorConfig) | Not supported | Settings come from the on-screen options only |
| Offline use | Supported | Works without a connection once loaded |

## Limits & notes

- Input is limited to 1 million characters. Above 100,000 characters auto-run pauses and you press “Run”.
- Formatting depends on Prettier and JavaScript minifying on Terser, so syntax they do not support yet is reported as a syntax error with its position.
- Language detection is a heuristic. Choose the language manually if it guesses wrong.
- HTML minifying does not interpret CSS, so elements made whitespace-sensitive by an external stylesheet (\`white-space: pre\`) are not detected; inline style attributes are.
- Anything not minified is left as written (inline \<script\> with a non-JavaScript type, scripts that cannot be parsed).
- Syntax coloring is approximate (not a parser) and does not affect what you copy or download.
- Formatting and minifying work on a phone, but for long code and side-by-side checks a PC’s wider screen is easier.

## Privacy & safety

The code you enter and any files you open are processed only inside your browser. Nothing is uploaded or stored, so confidential source is safe to format or minify. Closing the page clears everything.

## FAQ

### Is the result the same as Prettier?

Formatting uses Prettier 3.9.10, so the same settings give the same result. This tool does not read .prettierrc, so everything except the on-screen options (indent, width, quotes, semicolons, trailing commas) stays at Prettier’s defaults.

### Can minifying change how the code behaves?

JavaScript goes through Terser’s standard compression, and tests check that the same input gives the same result before and after. Code that depends on toString() output, or on local variable names themselves (via eval or new Function), can still change. Turning off “Shorten local variable names” keeps variable names and also keeps function and class names (Function.prototype.name).

### Can TypeScript be minified?

No. Stripping types needs a compile step that this tool does not do. Convert to JavaScript with tsc or esbuild first, then minify it as JavaScript. Formatting TypeScript works.

### Does HTML minifying break \<pre\>?

No. The contents of \<pre\>, \<textarea\> and elements with an inline white-space rule are not touched at all. Runs of whitespace in normal text become one space, which renders the same in HTML. &nbsp; is not treated as whitespace and stays as it is.

### Does it obfuscate code?

No. Local names are shortened, but nothing is done to make the source unreadable. Code you ship to clients can be turned back into something close to the original with any formatter.

### Is my code sent to a server?

No. Formatting and minifying run in your browser (in a Web Worker); nothing is sent to LIBRA Works or any third party.
