JavaScript & TypeScript Formatter
Format JavaScript, TypeScript, JSX and TSX properly with Prettier.
To format JavaScript or TypeScript, paste your code and it is parsed into an abstract syntax tree by Prettier and reprinted with consistent style. Because it parses rather than pattern-matches, template literals, JSX and comments survive intact, and a syntax error is reported with its location.
Runs in your browser- Engine
- Prettier, running in your browser
- Correctness
- AST-based — output is always valid syntax
- Privacy
- Runs entirely in your browser — nothing is uploaded
- Cost
- Free, unlimited, no sign-up
Frequently asked questions
Why does the formatter reject my code?
Does formatting change what my code does?
How to use the javascript & typescript formatter
- 1Enter or paste your code.
- 2Choose the language.
- 3Turn "Semicolons" on or off as needed.
- 4Turn "Single quotes" on or off as needed.
- 5Set the line width.
- 6Set the indent size.
- 7Turn "Indent with tabs" on or off as needed.
- 8The result appears immediately — copy or download it.
Embed this tool
Put the working javascript & typescript formatter on your own site. It runs in your visitors' browsers exactly as it does here — free, no account, nothing uploaded.
Share this tool
Related tools
CSS, SCSS & Less FormatterFormat stylesheets with consistent indentation, spacing and property ordering.HTML FormatterFormat and indent HTML properly, preserving inline elements and whitespace sensitivity.JSON to TypeScript ConverterGenerate TypeScript interfaces, Zod schemas, Go structs, Python dataclasses or Rust structs from JSON.Markdown FormatterTidy Markdown — normalise headings, lists, tables and emphasis markers.JSON Formatter & ValidatorFormat, validate, repair and analyse JSON — with errors that point at the exact line.SQL FormatterFormat and indent SQL queries for MySQL, PostgreSQL, SQLite, SQL Server and BigQuery.
Last updated
More data & format tools