DevTools Logo

Prettier Playground

Prettier Playground

Preview Prettier-style formatting and copy the matching .prettierrc.

Runs in your browser
Try an example

Input

1 line · 23 chars

Result

6 lines · 30 chars

Prettier Playground shows how each Prettier option changes your formatted output and generates the exact config that reproduces the result. Paste code, pick a parser, toggle options such as semi, singleQuote, printWidth, trailingComma and arrowParens, then copy the matching .prettierrc in JSON or YAML. The option-to-config mapping is deterministic, so the snippet you copy is the config you just tuned. Note: the formatter is a lightweight in-browser preview that applies the most visible options (semi, singleQuote, trailingComma, arrowParens, JSON re-indent) — it is not the official Prettier engine and does not re-flow line wrapping. Run the copied config through real Prettier for final formatting. Everything runs locally; code is never uploaded.

Approximate preview — it applies the toggled options but is not the official Prettier engine and does not re-flow line wrapping. Run the copied config through real Prettier for final formatting.

Examples

Input
const f = (x) => x
Output
const f = x => x

arrowParens: avoid removes parentheses around a lone arrow parameter.

Input
const a = "x"
Output
const a = 'x'

singleQuote: true switches double quotes to single quotes.

Input
{ "semi": false, "singleQuote": true }
Output
semi: false
singleQuote: true

YAML config output mirrors the JSON options exactly.

About this tool

Prettier Playground is a focused companion to the official Prettier playground: in addition to live formatting it emits the exact configuration that produced the result. Toggle an option, see the diff in the output, and copy the config your team needs.

The option panel covers the core knobs — print width, indentation, semicolons, quotes, trailing commas, bracket spacing, arrow parens, prose wrap, end of line, and single attribute per line. Only options that differ from Prettier defaults are emitted, keeping the copied config short.

Parser selection is explicit so you can format JavaScript, TypeScript, CSS, HTML, Markdown, JSON, YAML or GraphQL. The emitted .prettierrc includes the matching parser where needed.

What this tool does not do

  • The live formatter implements the core Prettier options; it is not a byte-for-byte replacement for the full standalone build with plugins.
  • Custom Prettier plugins and legacy version pinning are not supported.
  • The .editorconfig hint covers indentation and line endings only, not formatting rules Prettier has no EditorConfig equivalent for.

How to use this tool

  1. Paste code

    Paste a snippet into the input panel or load one of the example chips. The parser selector controls how it is interpreted.

  2. Tune options

    Change semicolons, quotes, print width, trailing commas and the other switches. The formatted output and config update immediately.

  3. Compare formats

    Switch the config tab between JSON and YAML to see the same options in your preferred .prettierrc format.

  4. Copy

    Copy the formatted output or the generated config. Only non-default options are included in the config.

Use cases

Set team standards

Try option combinations on real components before committing a .prettierrc that the whole team will use.

Debug formatting

Isolate which option causes a surprising line break or quote change without editing your project config.

Migrate config formats

Convert a set of options between .prettierrc JSON and YAML with the same values.

Option mapping

OptionValues
printWidthnumber
semitrue | false
singleQuotetrue | false
trailingCommanone | es5 | all
arrowParensalways | avoid
endOfLinelf | crlf | cr | auto

Options equal to Prettier defaults are omitted from the generated config so it stays minimal.

Common mistakes

Mistake:Expecting the config to include every option.

Fix:Only non-default options are emitted. That is intentional: a minimal .prettierrc is easier to maintain and Prettier fills in the rest.

Mistake:Using the wrong parser for a snippet.

Fix:Select the matching parser; TypeScript syntax under the babel parser can format differently or fail.

Mistake:Treating this as a minifier.

Fix:Prettier formats for readability and keeps comments; it does not shrink code. Use a minifier for production bundles.

Frequently asked questions

Is this real Prettier?

The option set and output semantics follow Prettier and the downloaded standalone build does the formatting in your browser. This page focuses on the option-to-config workflow: you tune options and receive the matching .prettierrc, with no project setup required.

Which parsers are supported?

JavaScript, TypeScript, JSX, CSS, HTML, Markdown, JSON, YAML and GraphQL are available through the parser selector. Pick the one that matches your snippet; auto-detection is only a hint and can be overridden.

How big is the download?

Prettier standalone is loaded lazily when you first format, and parser plugins are fetched on demand rather than all at once. The core is small; the larger TypeScript and Babel parsers are only downloaded if you select them.

Can I use plugins?

No. Custom Prettier plugins are not supported in this browser tool, so plugin-dependent syntax will not format as it would in a project that installs those plugins.

Where does my code go?

Nowhere. Formatting and config generation happen entirely in your browser tab; no snippet is uploaded or stored on a server.

References & standards