Skip to content

About

Export a VS Code color theme as a Zed theme family. One bash script, one jq program, no build step.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vsc2zed

Export a VS Code color theme as a Zed theme family. One bash script, one jq program, no build step.

$ vsc2zed MaoSantaella.night-wolf
converting MaoSantaella.night-wolf
  fetching MaoSantaella.night-wolf from the marketplace
  - Night Wolf (dark blue)
  - Night Wolf (dark blue) (No Italics)
  - Night Wolf (dark gray)
  - Night Wolf (dark gray) (No Italics)
  - Night Wolf (gray)
  - Night Wolf (gray) (No Italics)
  - Night Wolf (black)
  - Night Wolf (black) (No Italics)
✓ wrote themes/night-wolf.json

Add --install and the file lands in ~/.config/zed/themes/, where Zed picks it up the next time it starts. All eight Night Wolf variants show up in the theme selector.

Or run it with no arguments and it finds the themes you already have installed in VS Code or Cursor:

$ vsc2zed
vsc2zed 1.1.0

Pick the extension to convert

Found 3 theme extension(s) installed locally:

   1  VS Code            Night Wolf                           8 theme(s)
   2  VS Code            Dracula Theme                        4 theme(s)
   3  Cursor             GitHub Theme                         9 theme(s)

  m   fetch from the marketplace instead
  p   give a path to a .vsix, folder, or theme file
  q   quit

Choose [1-3, m, p, q]: 1

This extension has 8 themes:
   1  Night Wolf (dark blue)
   2  Night Wolf (dark blue) (No Italics)
   ...

Convert all 8, or pick some (e.g. 1,3)? [all] 1,5

You can replace parts of the theme(s) picked above (the base) with
colors from a second theme (the donor). Everything else stays as-is.
Mix from a donor theme? [y/N] n

About to convert
  Base:   Night Wolf (dark blue), Night Wolf (gray) (from Night Wolf)

Install into /home/you/.config/zed/themes? [Y/n] y

converting Night Wolf
  - Night Wolf (dark blue)
  - Night Wolf (gray)
✓ wrote /home/you/.config/zed/themes/night-wolf.json

Preview

  Night Wolf (dark blue)
    ui       ███ ███ ███ ███ ███
    syntax   ███ ███ ███ ███ ███ ███
    accents  ███ ███ ███ ███ ███ ███
    players  ███ ███ ███ ███

  Night Wolf (gray)
    ...

The swatches render in your terminal's colors; with mixing on, the rows that came from the donor say so.

Why another one of these

There is a Rust port already. It works, but installing a toolchain to move a JSON file into a different JSON file is more than the job needs. This does the same work with tools you already have: bash, jq, awk, and unzip.

The interesting part is not the file I/O. It is deciding that Zed's element.hover should come from VS Code's list.hoverBackground, and that when a theme leaves that key out you fall back to the foreground at 8% over the background. That knowledge lives in one table in lib/mappings.jq, which is the file you will actually want to read or edit.

Install

Nothing to clone. Run it straight from GitHub and it drops you into the interactive picker:

curl -fsSL https://raw.githubusercontent.com/roverflow/vscode-zed-theme-exporter/main/vsc2zed | bash

Arguments go after bash -s --:

curl -fsSL https://raw.githubusercontent.com/roverflow/vscode-zed-theme-exporter/main/vsc2zed \
  | bash -s -- --install MaoSantaella.night-wolf

Run this way, the script fetches its lib/ files from the same branch into a temporary directory first. Set VSC2ZED_LIB_URL to point that somewhere else: a fork, a branch, or a local file:// path.

Or clone it, and lib/ is found next to the script with no fetching:

git clone https://github.com/roverflow/vscode-zed-theme-exporter
cd vscode-zed-theme-exporter
./vsc2zed --help

You can also put vsc2zed and lib/ somewhere on your PATH together.

Requirements: bash 4+, jq 1.6+, awk, unzip. curl only for marketplace IDs and the no-clone form.

Usage

vsc2zed [OPTIONS] <SOURCE>...

SOURCE is whichever form of the theme you happen to have:

vsc2zed MaoSantaella.night-wolf            # marketplace publisher.extension
vsc2zed ~/Downloads/night-wolf-2.5.0.vsix  # a downloaded package
vsc2zed ~/src/my-theme/                    # an unpacked extension
vsc2zed themes/my-color-theme.json         # a single theme file

Options:

Option Effect
-o, --out DIR Where to write. Defaults to ./themes.
--name NAME Override the theme family name.
--author NAME Override the author. Defaults to the extension publisher.
--appearance dark|light Force the appearance for every theme.
--install Also copy into Zed's user themes directory.
--stdout Write to stdout instead of a file.
-q, --quiet Errors only.
-i, --interactive Pick from what VS Code or Cursor already has installed.
--list-local Print that list and exit.
--only GLOB Convert only matching themes. Repeatable.
--mix-from SOURCE Graft part of another theme onto the ones being converted. Same forms as SOURCE.
--mix-theme GLOB Which theme in --mix-from, if it has more than one. Matches like --only.
--mix-parts LIST Comma-separated parts to take: ui, accents, players, syntax. Defaults to syntax.

With no SOURCE at a terminal, vsc2zed goes interactive.

--only takes a case-insensitive glob matched against the whole theme name. Parentheses are literal, since theme names are full of them:

vsc2zed --only '*(black)' --install MaoSantaella.night-wolf

Because the glob is anchored, that selects Night Wolf (black) and leaves Night Wolf (black) (No Italics) alone.

One extension becomes one Zed theme family. An extension shipping eight themes produces one file with eight entries, which is how Zed expects related themes to be packaged.

Finding local themes

--list-local and interactive mode look for user-installed extensions in the usual places: ~/.vscode/extensions, plus the equivalent directories for VS Code Insiders, VSCodium, Cursor, Windsurf, Trae, and the Flatpak builds. The path hangs off $HOME on every platform, so there is no per-OS special casing.

Point it somewhere else with VSC2ZED_EXTENSION_ROOTS, a :-separated list of directories. An entry can be a bare path or Label|path:

VSC2ZED_EXTENSION_ROOTS="Work Cursor|/opt/cursor/extensions" vsc2zed --list-local

Extensions that store their display name as a %key% reference into package.nls.json get resolved, so the picker shows Localized Name rather than %ext.displayName%.

What it handles

VS Code themes are messier than the format suggests, so the converter deals with a few things you would otherwise hit by hand.

Comments and trailing commas. VS Code reads theme files with a permissive parser. jq will not. lib/jsonc.awk strips both, and only runs when jq has already refused the file.

include chains. A theme can extend another and override parts of it. Colors merge key by key, token rules concatenate with the base first.

Placeholder names. Night Wolf ships all eight of its themes with "name": "themename". The label in package.json is authoritative, so that is what the converter uses.

Rules that split color and style. Night Wolf colors meta.function-call in one rule and italicizes it in another. VS Code merges those. Replacing the first with the second, which is the obvious implementation, silently drops the color. The scope index merges instead.

Scopes narrower than the capture. A theme that colors keyword.control.flow but never keyword leaves Zed's keyword capture unstyled. When no prefix match exists, the converter takes the shortest descendant scope instead.

Colors Zed has and VS Code does not. Dim ANSI colors, player colors past the first, and the .background and .border variants of every git status. These are derived from the palette rather than left empty.

The output covers 141 of the 142 color keys in Zed's theme schema. The one gap is background.appearance, a window transparency setting with no VS Code equivalent.

Extending the mapping

lib/mappings.jq holds two tables. Each maps a Zed key to an ordered list of candidates, and the first candidate that resolves wins:

"element.hover": ["list.hoverBackground", "toolbar.hoverBackground", "$fg@14!"],
"keyword":      ["keyword.control", "keyword", "storage.type", "storage.modifier"],

UI candidates use a four-part notation:

Form Meaning
list.hoverBackground A VS Code workbench color key.
$accent A slot in the derived base palette (bg, fg, accent, border, and six hues).
#ff00ff A literal.
...@40 That color at alpha 0x40.
...! Composite the result onto the background, making it opaque.

Suffixes combine left to right, so foreground@40! is the foreground at 25% flattened onto the background.

Syntax candidates are TextMate scopes. Lookup walks each scope's dotted prefixes, so listing keyword.control also catches a theme that only wrote a rule for keyword.

If a mapping produces a bad color for some theme, the fix is usually one line in that file. You should not need to touch lib/convert.jq.

Mixing themes

--mix-from grafts part of a second theme onto the ones being converted, after both have gone through the normal conversion:

vsc2zed --mix-from dracula-theme.theme-dracula --mix-parts syntax \
  --install MaoSantaella.night-wolf

That converts every selected Night Wolf variant as usual, then replaces each one's syntax colors with Dracula's. Four parts can be mixed in, matching how convert.jq is structured internally:

Part What it covers
ui Window chrome, panels, text, diagnostics, version control
accents Bracket-pair colors
players Cursor and selection colors
syntax Function, keyword, string, and other token colors

--mix-parts takes a comma-separated list and defaults to syntax alone if omitted. ui merges key by key, so anything the donor leaves unset falls back to the base theme's own value. The other three parts replace wholesale: accents and players are ordered lists and syntax is a set of per-scope rules, where a partial merge would land somewhere inconsistent rather than blended.

If --mix-from resolves to more than one theme, narrow it with --mix-theme, which matches labels the same way --only does:

vsc2zed --mix-from MaoSantaella.night-wolf --mix-theme '*(black)' \
  --mix-parts ui,accents MyTheme.some-extension

Interactive mode (-i) asks after you pick the themes to convert: "Mix from a donor theme?" Say yes and it runs the same picker again for the donor, asks which theme in it is the donor and which parts to take, recaps base and donor before writing anything, and ends with a color preview where donor-supplied rows are labelled.

The merge itself is one pure function, lib/mix.jq, that only ever looks at already-converted Zed JSON. It never reads a VS Code color or scope, so it composes with everything above it in the pipeline without needing to know about any of it.

Layout

vsc2zed              CLI. Argument parsing, source adapters, file I/O.
lib/mappings.jq      The two tables. Data only.
lib/convert.jq       One VS Code theme in, one Zed theme out. A pure function.
lib/mix.jq           Graft parts of one converted theme onto another. A pure function.
lib/jsonc.awk        JSONC to strict JSON.
lib/interactive.sh   Local editor discovery and the picker.
themes/              Output.

lib/interactive.sh is sourced only for --interactive and --list-local, and it ends by setting the same variables a command line would have set. Interactive mode fills in arguments. It is not a second conversion path, so nothing in it can change how a theme converts.

lib/convert.jq never touches the filesystem, so you can drive it directly:

jq -L lib --arg name "My Theme" --arg appearance "" -f lib/convert.jq theme.json

That is also how most of the tests call it.

Tests

There is no automated suite right now; it was removed along with CI. The checked-in Night Wolf export doubles as the end-to-end regression check, since it is the only artifact built from a real published extension: re-run that conversion and diff the output.

Known limits

Some VS Code concepts have no Zed equivalent and are dropped: the minimap, peek view, notification, and debug toolbar colors, bracket pair guide backgrounds, and per-language tokenColors overrides. Nothing is lost that Zed could render.

Light themes work. I checked against GitHub's theme extension, which ships four light variants alongside its dark ones, including a high contrast one. Still, far more dark themes have been through this than light ones, so if a light theme comes out wrong, the mapping table is the place to look.

Mixing does not re-run enforce_distinct. Each theme resolves its own color collisions (say, text and text.muted landing on the same color) before mixing ever sees it, but grafting one theme's ui onto another, key by key, can reintroduce a collision that neither side's own pass anticipated. Rare enough not to special-case; if a mixed theme loses some visual hierarchy, this is why.

License

MIT. The themes under themes/ remain the property of their original authors, whose licenses apply to them.

About

Export a VS Code color theme as a Zed theme family. One bash script, one jq program, no build step.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages