๐ Runs in your browser โ nothing is uploadedโ Free, no signup
TypeScript Formatter
Paste TypeScript or JavaScript to format it with Prettier. Choose indentation, line width, single or double quotes and semicolons.
0 characters
Formatted TypeScript
When should you use the TypeScript Formatter?
- Formatting a snippet from Stack Overflow, ChatGPT or a blog
- Checking how Prettier will format code with different options
- Tidying code before sharing it
How to use the TypeScript Formatter
- 1
Paste code
Paste TypeScript or JavaScript, including JSX-free React code.
- 2
Choose options
Indent, line width, quotes and semicolons โ like your .prettierrc.
- 3
Check errors
Syntax errors show the line and column.
- 4
Copy
Copy the formatted code or download index.ts.
Examples
Type and function
Before
type A={a:number,b?:string};function f(x:A):number{return x.a}After
type A = { a: number; b?: string };
function f(x: A): number {
return x.a;
}Common errors and how to fix them
SyntaxError- The code has a syntax error at the line shown โ often a missing bracket or an unterminated string.
JSX doesn't format- This page uses the TypeScript parser for .ts files. JSX/TSX isn't supported here.
More from Code Formatters & Minifiers
Free tools that run in your browser โ no signup, nothing uploaded.
SQL Formatter & Beautifier
Format SQL queries for MySQL, PostgreSQL, SQL Server, SQLite and more.
CSS Minifier & Compressor
Optimize CSS by removing whitespace and comments to accelerate page load time.
JS Minifier & Compressor
Compress JavaScript to improve website speed and performance.
XML Formatter & Validator
Format, validate and minify XML, with errors shown by line and column.
HTML Formatter & Beautifier
Beautify or minify HTML with clean, consistent indentation.
Markdown Editor & Preview
Write Markdown with a live preview and copy the HTML.
HTML to JSX Converter
Convert HTML to valid React JSX โ className, style objects and more.
SVG to React Component
Turn SVG markup into a React component with camelCase attributes.
HTML to Markdown Converter
Convert HTML to clean Markdown, including tables and code blocks.
TypeScript Formatter FAQ
No โ it formats code only. Use tsc or your editor for type errors.
Yes. JavaScript is valid input for the TypeScript parser.
Indentation (tabWidth / useTabs), line width (printWidth), quotes (singleQuote) and semicolons (semi). Everything else uses Prettier's defaults.
If your project uses the same options, yes โ this runs the real Prettier.
Not on this page โ it formats .ts and .js code without JSX.
No. Everything runs in your browser, so your code never leaves your device.
