In VS Code; you can simply select the lines you want to sort and then CMD + SHIFT + P (Ctrl + Shift + P on Windows) and search for Sort lines Ascending/Descending.

GitHub
github.com › prettier › prettier › issues › 1096
Option to sort object keys · Issue #1096 · prettier/prettier
March 28, 2017 - Would you be open to a pull request to add the option for prettier to sort object keys? Currently I'm linting on this but having Prettier take care of it would be neat. E.g. Before: { b: {}, a: {}, } After: { a: {}, b: {}, }
Published Mar 28, 2017
npm
npmjs.com › package › prettier-plugin-sort-json
prettier-plugin-sort-json - npm
A plugin for Prettier that sorts JSON files by property name. This plugin adds a JSON preprocessor that will sort JSON files alphanumerically by key.
» npm install prettier-plugin-sort-json
Published Jan 13, 2026
Version 4.2.0
Top answer 1 of 5
27
In VS Code; you can simply select the lines you want to sort and then CMD + SHIFT + P (Ctrl + Shift + P on Windows) and search for Sort lines Ascending/Descending.

2 of 5
12
Lots of plugins are available for VSCode. "Sort" by "Henrik Sjööh" works nicely.
After installing the plugin, highlight the interface and press alt+shift+s (option+shift+s on MacOS) and the interface will be reordered.
GitHub
github.com › nedjulius › prettier-plugin-stylex-key-sort
GitHub - nedjulius/prettier-plugin-stylex-key-sort: Prettier plugin that auto-sorts StyleX keys
Starred by 11 users
Forked by 2 users
Languages TypeScript 98.6% | JavaScript 1.4%
GitHub
github.com › prettier › prettier › issues › 3926
Sort object literals/arrays [request/idea] · Issue #3926 · prettier/prettier
June 24, 2017 - In some cases it would be nice if prettier could automatically keep an object or array sorted Input: // prettier-sort { z: 5, d: 3, e: 7, a: ` multiline thing `, 'quoted-key': 8, } // prett...
Published Feb 08, 2018
GitHub
github.com › Gudahtt › prettier-plugin-sort-json
GitHub - Gudahtt/prettier-plugin-sort-json: A plugin for Prettier that sorts JSON files by property name.
A plugin for Prettier that sorts JSON files by property name. This plugin adds a JSON preprocessor that will sort JSON files alphanumerically by key.
Starred by 122 users
Forked by 16 users
Languages TypeScript 95.0% | JavaScript 4.6% | Shell 0.4%
Hacker News
news.ycombinator.com › item
> JSON can be made prettier by sorting the JSON object members by element keys. ... | Hacker News
February 24, 2021 - This seems to be a bad idea. The JSON language spec has ORDERED object members. But the order is arbitrary (precisely the one given in the JSON string) and does not have to be the lexicographic · Sorting the object members by default would introduce problems whenever the order matters to the ...
Palantir
palantir.github.io › tslint › rules › object-literal-sort-keys
Rule: object-literal-sort-keys
"object-literal-sort-keys": [ true, "ignore-blank-lines", "ignore-case", "locale-compare", "match-declaration-order", "shorthand-first" ]
ESLint
eslint.org › docs › latest › rules › sort-keys
sort-keys - ESLint - Pluggable JavaScript Linter
It basically sorts numerically, instead of sorting alphabetically. So the number 10 comes after the number 3 in Natural Sorting. allowLineSeparatedGroups - if true, the rule allows to group object keys through line breaks. In other words, a blank line after a property will reset the sorting of keys.
GitHub
github.com › prettier › prettier › issues › 4040
Idea: sort package.json keys · Issue #4040 · prettier/prettier
February 25, 2018 - It would be really cool to integrate something like this directly inside Prettier.
Published Feb 25, 2018
GitHub
github.com › tocttou › prettier-sort-destructure
GitHub - tocttou/prettier-sort-destructure: A prettier parser that sorts the destructured keys in object assignments
A prettier parser that sorts the destructured keys in object assignments - tocttou/prettier-sort-destructure
Author tocttou
Stack Exchange
vi.stackexchange.com › questions › 46001 › how-to-make-eslint-prettier-sort-object-keys-and-imports-alphabetically-on-sav
lazyvim - How to make ESLint / prettier sort object keys and imports alphabetically on save? - Vi and Vim Stack Exchange
I am currently switching from VSCode, which automatically reorders object keys and imports when I save my JS/React files. Everything else works, like if certain lines are not indented it'll indent ...
Lightrun
lightrun.com › answers › prettier-prettier-option-to-sort-object-keys
Option to sort object keys
So it’s sometimes easier to just say: no we’re not going to change the semantics to avoid having to deal with the downfall. Read more comments on GitHub > ... To sort the properties of an object by their keys you can make use of the Object.keys ...
GitHub
github.com › Siilwyn › prettier-plugin-css-order
GitHub - Siilwyn/prettier-plugin-css-order: Prettier plugin to sort CSS declarations in a certain order. · GitHub
Using css-declaration-sorter under the hood. Following the Prettier plugin guidelines, this package depends on Prettier as a peer dependency: npm install prettier-plugin-css-order --save-dev · To enable the plugin use the Prettier API, CLI or configuration file. For example using the JS configuration: { plugins: ["prettier-plugin-css-order"] } This plugin adds two configurable keys to Prettier: cssDeclarationSorterOrder defaults to concentric-css.
Author Siilwyn
npm
npmjs.com › package › prettier-plugin-css-order
prettier-plugin-css-order - npm
Using css-declaration-sorter under the hood. Following the Prettier plugin guidelines, this package depends on Prettier as a peer dependency: npm install prettier-plugin-css-order --save-dev · To enable the plugin use the Prettier API, CLI or configuration file. For example using the JS configuration: { plugins: ["prettier-plugin-css-order"] } This plugin adds two configurable keys to Prettier: cssDeclarationSorterOrder defaults to concentric-css.
» npm install prettier-plugin-css-order
Published Jan 02, 2026
Version 2.2.0
Author Selwyn