CodecKit
Convert text between encodings and formats inside VS Code: Base64, JSON, plain text, with more to come.
Usage
- Open the Command Palette (
Ctrl+Shift+P / Cmd+Shift+P).
- Run CodecKit: Open Converter.
- Pick an input format on the left and an output format on the right, then paste or type into the left box.
The output updates as you type. If the input can't be converted, an error explains why.
- ⇄ Swap: flips the two formats and moves the output into the input, for a quick round trip.
- Paste / Clear / Copy: work through the system clipboard.
- Try a sample: fills the input with an example in the selected format.
- The status bar shows the conversion, the number of bytes decoded and how long it took.
The panel follows your VS Code theme, including high-contrast themes, and turns off animations if your OS is set to reduce motion.
Any format can be converted to any other.
| Format |
As input |
As output |
| Base64 |
Standard (+/) or URL-safe (-_) alphabet, padded or unpadded. Whitespace and line breaks are ignored, so MIME-wrapped Base64 works. |
Standard alphabet, padded. |
| JSON |
Must be valid JSON (RFC 8259: no comments, trailing commas or single quotes). Your text is used exactly as typed, including its formatting. |
Pretty-printed with 2-space indent. Only whitespace changes: big integers, duplicate keys, number spelling (1e3, -0) and escapes (\u00e9) are kept exactly. |
| Text (UTF-8) |
Any text. |
Fails if the bytes aren't valid UTF-8, rather than inserting �. |
Examples
| From |
To |
Input |
Output |
| Base64 |
JSON |
eyJhIjpbMSwyXX0= |
{ "a": [1, 2] }, pretty-printed |
| Base64 |
JSON |
JWT payload, e.g. eyJzdWIiOiIxMjMifQ |
{ "sub": "123" }, pretty-printed |
| JSON |
Base64 |
{"a":1} |
eyJhIjoxfQ== |
| Base64 |
Text |
aGVsbG8= |
hello |
Validation errors
| Error |
Meaning |
Invalid Base64: unexpected character 'x' |
A character outside the Base64 alphabets. |
Invalid Base64: mixes standard (+/) and URL-safe (-_) alphabets |
Both +// and -/_ appear; the input is probably corrupted. |
Invalid Base64: length is not valid |
The input is truncated. |
Invalid Base64: incorrect "=" padding |
Too much or too little padding, or data after the padding. |
Invalid JSON: … |
The JSON parser's message, e.g. an unexpected token. |
Data is not valid UTF-8 text |
The decoded bytes are binary, not text. |
Development
npm install
npm run compile # type-check, lint, build to dist/
npm run watch # rebuild on change (used by F5)
npm run test:unit # fast codec tests with plain mocha, no VS Code needed
npm test # full test suite inside a VS Code instance
Press F5 in VS Code to launch an Extension Development Host with the extension loaded.
Project layout
src/
codecs/ one file per format, plus the registry and convert()
protocol.ts message types shared by the extension and the webview
panel.ts the converter webview panel (extension side)
extension.ts activation, command registration
webview/ UI: index.html, styles.css, main.ts (browser side)
test/codecs/ unit tests for codecs and conversions
docs/
adding-a-codec.md
How conversion works
Every format is a codec that converts its text to raw bytes and back. A conversion decodes the input to bytes, then encodes those bytes in the output format:
input text ──decode(from)──▶ bytes ──encode(to)──▶ output text
So one new codec is immediately convertible to and from every existing one.
To add a format, see docs/adding-a-codec.md.
License
MIT