Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>TS/JS Sort ImportsNew to Visual Studio Code? Get it now.
TS/JS Sort Imports

TS/JS Sort Imports

vladbelozertsev

|
15 installs
| (0) | Free
Alphabetically, like strings.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

About

I didn't find similar extension, so i decide to create my own. Extension for sorting TS/JS imports alphabetically, like you sort them by "Sort lines" extension. Extension works for js/ts and jsx/tsx type of files. Extension sort imports in both directions: horizontal and vertical.

Usage: command

Press "Ctrl+Shift+P" and tap:
"Sort TS imports"

Usage: auto

Add to your settings.json file:
ts-imports-sort-alphabetically.sortOnSave": true

Caution

Extension edit your imports and remove all non-import strings between import ... statements. It means comments or code will be removed.
For example:
import { A } from "./a"; // some comment
const foo = "bar";
import { B } from "./b";
Extension will remove // some comment and const foo = "bar"; strings.

Disable

You can disable auto sorting for some files, by adding this comment to document:
disable-sort-imports

Settings

ts-imports-sort-alphabetically.sortOnSave - Boolean, default: true. Sort imports before file will be saved.

ts-imports-sort-alphabetically.printWidth - Number, default: 80. Prittier-like print width. Max width for single lined import. If bigger, it will be breaked into few lines.

ts-imports-sort-alphabetically.importsDevide - Boolean, default: true. Add empty line between import's and import type's statements. See image examples below.

ts-imports-sort-alphabetically.typesTop - Boolean, default true. Position of "import type..." statements relative to "import" statements. See image examples below.

ts-imports-sort-alphabetically.bracketSpacing - Boolean, default true. Spaces between import brackets "{space...space}".

Images:

example-image

example-image Before sort / After sort

example-image

example-image With / Without devider

example-image Print width

example-image

example-image Type imports top / bottom

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft