Skip to content
XUtilHub

JavaScript Formatter & Beautifier – JS, JSX & TypeScript

Format and beautify JavaScript, JSX and TypeScript code with Prettier. Choose indentation, line width, quotes and semicolons.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the JavaScript Formatter

Clean up JavaScript, JSX and TypeScript in seconds with Prettier, the formatter used by most modern projects. Choose indentation, line width, quote style and semicolons.

Key features

  • JavaScript, JSX, TypeScript and TSX
  • Powered by Prettier
  • Choose indentation and line width
  • Single or double quotes
  • With or without semicolons
  • Private: your code never leaves your browser

Beautify JavaScript in one click

Paste minified, messy or inconsistently formatted JavaScript or TypeScript and get clean code formatted with Prettier, the formatter used by React, Vue, Next.js and most modern projects.

Before and after

const sum=(a,b)=>{if(!a){return b}return a+b};export default sum

becomes

const sum = (a, b) => {
  if (!a) {
    return b;
  }
  return a + b;
};
export default sum;

Options

OptionChoices
LanguageJavaScript / JSX, TypeScript / TSX
Indent2 spaces, 4 spaces, tab
Line width80, 100, 120
QuotesDouble, single
SemicolonsOn, off

JavaScript minifier, JSON formatter, and JSON to TypeScript.

How to use the JavaScript Formatter

  1. Paste your code into the input box, upload a file, or click Sample to try it out.
  2. Choose the options you want, such as indentation, line width or dialect.
  3. The result appears instantly in the output panel. Syntax errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

Can I format TypeScript?

Yes. Choose TypeScript / TSX in the Language option to format type annotations, interfaces, generics and TSX components.

Can it deobfuscate minified JavaScript?

It restores line breaks and indentation, which makes minified code much easier to read. It can't restore original variable names or comments that were removed.

Why does my code show a syntax error?

Prettier must be able to parse the code. The error shows the line and column of the problem. If you're formatting TypeScript, make sure TypeScript is selected.

Is my code sent to a server?

No. Prettier runs entirely in your browser, so proprietary code stays on your device.

Is my code uploaded anywhere?

No. Every developer tool runs entirely in your browser, so source code, configuration files and passwords never leave your device.

Which formatter do you use?

HTML, CSS and JavaScript are formatted with Prettier, the most widely used code formatter, so the output matches what most projects use. SQL uses sql-formatter, and minification uses Terser and CSSO.

Is there a size limit?

There's no fixed limit. Very large files (several megabytes) can take a few seconds, depending on your device.

Last updated:

Related Dev tools