Format JavaScript and TypeScript Code
Paste JavaScript or TypeScript and get consistently formatted code using Prettier's rules. Choose your team's style for quotes, semicolons and trailing commas, and syntax errors are pointed out by line and column.
How to format JavaScript
- Paste code, click Sample, or open a .js, .jsx, .ts or .tsx file up to 5 MB.
- Select the language: JavaScript/JSX or TypeScript/TSX.
- Set indentation, line width, trailing commas, single quotes and semicolons.
- Copy the formatted code or download it; fix any reported syntax error at the line shown.
Supported formats
- Input
- JavaScript, JSX, TypeScript, TSX
- Output
- Formatted code
- Maximum size
- 5 MB per file (limited by your device's memory)
Benefits
- Same output as Prettier in your editor, so pasted code matches your project's style.
- Understands modern syntax: JSX, TypeScript types, optional chaining, decorators and more.
- Syntax errors include an excerpt and caret, which doubles as a quick syntax checker.
Limitations
- There is no minify option; use a build tool such as esbuild or Terser for production bundles.
- Flow type annotations and proposals that Babel does not enable by default may fail to parse.
- Very large files (several MB) can take a few seconds to format on slower devices.
Privacy and security
Prettier and its parsers are loaded on demand and run inside this tab. Your code is not sent to any server.
Read our privacy policy for details about the site as a whole.
Frequently asked questions
Can it deobfuscate minified code?
It restores line breaks and indentation, which makes minified code readable, but it cannot restore original variable names that the minifier shortened.
Does formatting change behaviour?
No. Prettier only changes layout and equivalent syntax such as quote style. It may add semicolons where they prevent ambiguous automatic semicolon insertion.
Which Prettier version is used?
Prettier 3, with the Babel parser for JavaScript and the TypeScript parser for TypeScript.