How to use the CSS Formatter
- 1Paste your CSS.
- 2Choose indentation.
- 3Click Format and copy the result.
About the CSS Formatter
Reading minified CSS is painful. This formatter uses Prettier to produce consistently indented, readable stylesheets.
Great for debugging third-party styles or cleaning up legacy code.
When to use the CSS Formatter
Investigating a compact component stylesheet
When a component's CSS arrives on one long line, formatting makes selectors and declaration blocks easier to scan. Paste the stylesheet and choose two spaces, four spaces, or tabs before formatting. Use the readable output to investigate overrides and media queries without manually inserting line breaks throughout the original code.
Standardizing indentation before code review
A stylesheet assembled from several snippets may use inconsistent indentation that distracts reviewers from the actual changes. Format the combined CSS with your team's preferred indentation setting, then review the generated result. Keep formatting changes separate from behavioral edits when possible so the review can focus on one kind of change.
Preparing stylesheet examples for documentation
Readable CSS examples help colleagues understand how a layout is constructed. Paste a working snippet, format it consistently, and copy the output into your documentation draft. Inspect long values and nested blocks before publishing, especially when the example needs to fit within a narrow code panel or a printed guide.
Tips and best practices
- Choose indentation before clicking Format CSS. Changing the selector does not regenerate an existing result until you run the formatter again with the new setting.
- Use the first parse-error message as a starting point for inspection. Fix the source and rerun formatting rather than assuming the tool will repair malformed declarations.
- Review long declarations in context. The formatter uses a fixed print-width setting of 100 and does not provide a separate control for custom line widths.
- Keep selector and property changes out of a formatting-only review. Consistent presentation helps inspection, but it does not establish that the underlying stylesheet is correct.