JavaScript Formatter

Format and beautify JavaScript code with sensible defaults. Everything runs in your browser, so your source never leaves the page.

About this JavaScript formatter

This is a free online JavaScript formatter and beautifier. Paste a minified bundle, a messy snippet, or any JavaScript source into the input panel and you'll get a tidy, indented version in the output panel. Statements, blocks, and expressions are laid out on their own lines so the code is easy to read and review.

Features

  • Format JavaScript with 2 spaces, 4 spaces, or tab indentation.
  • Wrap long lines at 80, 100, or 120 columns.
  • Preserve existing identifiers, values, and string literals exactly.
  • Copy the result or download it as a .js file.

How it works

The tool uses the JavaScript beautifier from the open source js-beautify library, loaded into your browser on first use. It tokenizes the source, normalizes whitespace and line breaks, and writes the result back with your chosen indentation.

Privacy

Your code never leaves your browser. The whole tool runs locally as JavaScript on this page, so you can safely paste proprietary application code, third-party bundles, or anything else without it touching a server.

Frequently asked questions

Does this tool send my code anywhere?
No. Formatting happens entirely in your browser. The js-beautify library is fetched once from a public CDN, but your code is never uploaded.
Does it also minify JavaScript?
No. This tool only beautifies. For minification, use a build tool such as esbuild, swc, or Terser.
Will it change my code logic or identifiers?
No. The formatter only adjusts whitespace, line breaks, and indentation. It does not rename variables, reorder statements, or rewrite expressions.
Does it work with JSX, TypeScript, or modern syntax?
It handles modern ECMAScript (ES2022+), arrow functions, classes, async/await, and template literals. JSX and TypeScript-specific syntax (type annotations, generics) may not lay out perfectly. Use Prettier or your editor for the best result on those.