Consistent CSS property order across your project. CSSOrganizer sorts declarations in .css files and in plain CSS
<style> blocks in Vue single-file components. It supports Tailwind CSS @apply and has no runtime dependencies.
Install CSSOrganizer as a development dependency and run it from your project:
npm install --save-dev @derkatzelp/cssorganizer
npx css-organizerBy default, CSSOrganizer uses the current working directory as the project root. To use another directory, pass --root
(or -r). Relative paths are resolved from the directory where you run the command:
npx css-organizer --root "../my project"CSSOrganizer searches the configured folders and their subfolders. It edits files in place and skips writing files whose output is unchanged. Review the diff before committing: moving declarations can affect the CSS cascade, especially when shorthand and longhand properties are mixed.
Both override files are optional. Place them in the project root to use them instead of the bundled defaults.
Copy the bundled config.json to config.cssorg.json and adjust the values you need. The override
replaces the entire default file, so keep all keys.
| Option | Default | Description |
|---|---|---|
cssFolderPath |
"./src/assets" |
Folder to scan for .css files, relative to the project root |
vueFolderPath |
"./src/components" |
Folder to scan for .vue files, relative to the project root |
sortCssFiles |
true |
Process CSS files |
sortVueFiles |
true |
Process Vue single-file components |
showLogFiles |
true |
Log each file whose content changed |
showLogFolders |
true |
Log each processed folder |
Copy grouping.json to grouping.cssorg.json. CSSOrganizer reads the groups array in order and
follows each group's properties list. Unlisted declarations and @apply appear before listed properties, preserving
their relative order. Groups define the sort order; they do not insert headings or comments.
Before
.card {
color: navy;
width: 20rem;
display: block;
position: relative;
}After
.card {
position: relative;
display: block;
width: 20rem;
color: navy;
}- SCSS, Sass, and Less are not supported. Use CSSOrganizer only on Vue files with plain CSS styles.
- Only the first
<style>block in a Vue file is processed. Put its opening and closing tags on separate lines. - Declarations inside nested rules, such as rules within
@media, are not reordered.
Report bugs or suggest improvements on GitHub. CSSOrganizer is licensed under the MIT License and inspired by 9elements’ CSS Rule Order.