JS / TS Formatter

Beautify or minify JavaScript, TypeScript and JSX/TSX with Prettier options.

Your code is formatted locally in your browser with Prettier and Terser, and nothing is uploaded to a server.

Need to format styles too? Try the CSS Formatter.

About JS / TS Formatter

This js formatter beautifies or minifies JavaScript, TypeScript and JSX/TSX directly in your browser. As a JavaScript beautifier it runs Prettier with a full options panel, while minifying uses Terser to shrink code for production. Pick the Auto parser to detect the syntax automatically, or force JS/JSX or TS/TSX when you need a specific TypeScript formatter. Tune semicolons, quote style, tab width, print width and trailing commas to match your project's style. It is built for developers cleaning up messy snippets, QA engineers inspecting bundled output, and anyone who wants a quick prettier online alternative. Everything is processed locally in your browser, so your source code never leaves your device and nothing is uploaded to a server.

Features

How to use the JS / TS Formatter

  1. Paste your JavaScript or TypeScript into the input box.
  2. Choose Beautify to pretty-print or Minify to compress.
  3. Pick the parser: Auto, JS / JSX or TS / TSX.
  4. Adjust options like tab width, quotes, semicolons and trailing commas.
  5. Copy the formatted output from the result panel.

Example

Input

const  greet=(name)=>{return 'hi '+name}

Output

const greet = (name) => {
  return 'hi ' + name;
};

Beautified with default Prettier options (2-space indent, semicolons).

Common errors & troubleshooting

Frequently asked questions

What is the JS formatter and what can it do?
It is a browser-based tool that beautifies or minifies JavaScript, TypeScript and JSX/TSX. Beautifying runs Prettier with full style options and minifying runs Terser to compress code for production.
How do I format TypeScript or JSX with the JS formatter?
Choose the parser: JS / JSX, TS / TSX or Auto. Auto tries the TypeScript parser first and falls back to Babel, so plain JavaScript, JSX and TypeScript all format correctly.
Does the JS formatter use Prettier and Terser?
Yes. Beautifying uses Prettier and minifying uses Terser, so the output matches the same tools you would use in a real build pipeline.
Which style options can I control in the JS formatter?
You can toggle single versus double quotes and semicolons, switch between tabs and spaces, set tab width to 2 or 4, pick a print width of 80, 100 or 120, and choose trailing commas of none, es5 or all.
Does the JS formatter send my code anywhere?
No. Prettier and Terser both run entirely in your browser, so your code never leaves your device and nothing is uploaded to a server.

Related tools

All ArrayKit tools