๐Ÿ”’ 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.

Loading...

0 characters

Formatted TypeScript

Loading...

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. 1

    Paste code

    Paste TypeScript or JavaScript, including JSX-free React code.

  2. 2

    Choose options

    Indent, line width, quotes and semicolons โ€” like your .prettierrc.

  3. 3

    Check errors

    Syntax errors show the line and column.

  4. 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.
Related tools:ย JS Minifier ยท JSON to TypeScript ยท GraphQL Formatter

More from Code Formatters & Minifiers

Free tools that run in your browser โ€” no signup, nothing uploaded.

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.