Skip to content
AllToolsDesk

Popular

  • JSON Formatter & ValidatorFormat, minify and validate JSON with error locations.
  • CSS FormatterBeautify CSS, SCSS and Less with Prettier.
  • CSS MinifierCompress CSS and see the bytes saved.
  • JavaScript FormatterBeautify JavaScript and TypeScript.
  • JavaScript MinifierMinify JavaScript with Terser.
  • HTML FormatterIndent HTML, including inline CSS and JS.
  • JPG to PDFTurn images into a PDF, one per page.
  • Merge PDFCombine several PDFs into one file.
38 free toolsSee all tools

JavaScript Formatter

Beautify JavaScript and TypeScript with Prettier. Choose indentation, quotes, semicolons and line width. Your code stays in your browser.

Runs in your browser. Nothing is uploaded.

Ready.

About the JavaScript Formatter

Readable JavaScript is easier to review, debug and maintain. Code copied from a browser console, a minified bundle or a chat message often loses its line breaks, and different editors produce different spacing and quote styles.

This formatter uses Prettier, the formatter many teams run in their editors and CI, so the output matches what those projects expect. It reprints the code from its syntax tree, which means indentation, line breaks, quotes and semicolons become consistent while the behaviour stays the same. TypeScript, JSX and TSX are supported, and syntax errors are reported with their position, which also makes it a quick syntax check.

How to use the JavaScript Formatter

  1. 1

    Paste your code, open a .js or .ts file, or load the sample. Pasting, opening a file or loading the sample runs it automatically.

  2. 2

    Choose JavaScript or TypeScript, then set indentation, line width, semicolons and quote style.

  3. 3

    Press Format. Syntax errors are reported with their line and column.

  4. 4

    Copy the result or download it.

Examples

1Tidy a one-line function
Before
const sum=(a,b)=>{return a+b}
After
const sum = (a, b) => {
  return a + b;
};

Good to know

  • Formatting does not change behaviour, rename variables or remove unused code.
  • Code must be syntactically valid. JSX is supported in JavaScript mode; TSX in TypeScript mode.

Frequently asked questions

Is the output the same as running Prettier locally?

Yes, for the same options. This tool runs the official Prettier library in your browser.

Can it un-minify (deobfuscate) code?

It restores readable layout, but it cannot recover original variable names that a minifier shortened.

Is my code uploaded to a server?

No. Processing happens entirely in your browser, in a background thread. Your input is never sent to our servers or stored anywhere.

More tools that pair well with this one.

Browse all tools