CSS formatter
Reformat CSS into readable rules with consistent indentation and spacing.
- 1Add input
- 2Adjust settings
- 3Get your result
Tool input and files are processed in this browser without being uploaded.
Before you start
Use Prettier to format CSS source for reading and editing. The output stays in a text view: it is not applied to this page, and formatting does not fetch URLs referenced in the stylesheet.
How to use this tool
- Paste CSS into “CSS source” or choose a UTF-8 file. To use the file, clear the pasted text; to use pasted text alone, remove the file.
- Choose 2 spaces or 4 spaces under Indentation, then select “Format CSS”. Prettier may also adjust line breaks and quoted strings.
- Read the full result, then use “Copy result” or download formatted.css. If you change the input or options, run the formatter again to update the output.
Supported inputs and limits
Paste up to 1 MiB of UTF-8 text or choose one file up to 10 MiB. Filenames can contain up to 512 UTF-16 code units; characters such as emoji may count as two. Nonempty pasted text is formatted in preference to a selected file, but the file is still checked and read.
Worked example
Example input
a{color:red;margin:0}Example options
{}Example output
a {
color: red;
margin: 0;
}
When something does not work
If formatting fails, review the CSS and indentation. For a file, save a UTF-8 copy in another application and select it again, or remove it and paste the CSS instead. Reduce oversized input or shorten a long filename. After changing anything or cancelling a run, select “Format CSS” to run again.
Frequently asked questions
Are my files uploaded?
No. Your CSS and files are processed in your browser. While you move between tools in the same tab, a workspace may stay in memory, subject to size and time limits. Refreshing or closing the tab clears it. Download anything you want to keep.
Does formatting check CSS validity or browser support?
The parser can reject CSS it cannot read, but a formatted result does not prove that every property or value is valid or supported by a browser. This tool does not add vendor prefixes or minify your stylesheet. Review the CSS before using it on a site.
Documentation & further reading
Related tools
JSON formatter and string tools
Format or minify JSON, sort object keys, or convert between plain text and a JSON string.
JavaScript regex tester
Test JavaScript patterns against text and inspect matches, positions and capture groups.
Compare text
Compare two texts line by line, with a side-by-side view of changes.
HTML formatter
Format HTML source with consistent indentation and review the result as text.