consolelog.tools

TypeScript Formatter

Format & beautify TypeScript with Prettier — live, with precise code-frame errors and before/after stats.

About this ToolHow it works, benefits & use cases

The TypeScript Formatter beautifies TypeScript code using Prettier running directly in your browser. Paste a file or snippet — interfaces, type aliases, generics, async functions, decorators — and it reformats with Prettier's TypeScript parser, applying consistent indentation, line wrapping, and quote and semicolon style. The formatting options mirror Prettier's own: set the print width (the column at which lines wrap), the tab width, whether to use single quotes, whether to keep semicolons, and the trailing-comma style (none, ES5, or all). Output updates live as you type or change a setting. When the code cannot be parsed, you get a precise code-frame error with the message, line, and column and a caret pointing at the syntax problem. A footer shows before/after stats — input versus output line counts and byte sizes — and a banner appears when your code is already formatted. Copy the result or download it as a .ts file. It is free and fully local.

How to Use

  1. 1Paste your TypeScript into the input panel, or click "Load example" to load an unformatted sample.
  2. 2Adjust Options if needed: print width, tab width, trailing-comma style, single quotes, and semicolons.
  3. 3The formatted code renders live; click "Format TypeScript" to confirm.
  4. 4If parsing fails, read the code-frame error showing the message, line, column, and a caret at the issue.
  5. 5Copy the formatted code or download it as formatted.ts; the footer shows the line and byte change.

Key Benefits

  • Formats TypeScript with Prettier, including interfaces, generics, and decorators
  • Configurable print width, tab width, quotes, semicolons, and trailing commas
  • Live reformatting as you type or change an option
  • Precise code-frame error with line:column and a caret on parse failures
  • Before/after stats: input vs output line counts and byte sizes
  • "Already formatted" banner when no changes are needed
  • Runs entirely in the browser — code is never uploaded; copy or download as .ts

Common Use Cases

  • Tidying up a TypeScript snippet pasted from a Slack message or issue
  • Applying Prettier formatting without a local toolchain or editor plugin
  • Checking whether a file is already Prettier-clean before committing
  • Experimenting with print-width or trailing-comma settings to match a project style
  • Reformatting generated or minified TypeScript into readable code

Options

0 characters · live

Paste TypeScript above to format it live.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools