Base64 Encoder / Decoder
Visual Studio Code Extension to instantly encode and decode text to/from Base64 with full UTF-8 support, programming language quote preservation, and native multi-language localization.
🚀 Features
- Dedicated "Base64 >" Context Submenu: Both commands are neatly organized inside a dedicated right-click submenu, visible only when text is selected (
editorHasSelection).
- Smart Quote Preservation: If selected text in code (JavaScript, TypeScript, PHP, Python, Ruby, etc.) is enclosed in quotes (
"...", '...', or `...`), the quotes are automatically preserved around the resulting Base64 string (e.g., "Houssam" becomes "SG91c3NhbQ==" without breaking your code syntax).
- Direct In-Place Replacement: The selected text is replaced immediately with zero dialogs, popups, or manual copy-pasting.
- Full UTF-8 Support:
- Accented characters (
é, à, ç, ô, etc.)
- Emojis (
🚀, 👋, 🎉, etc.)
- Non-Latin scripts (Japanese, Arabic, Cyrillic, Chinese, etc.)
- Newlines (
\n, \r\n) and whitespace
- Strict Validation & Safety:
- Validates Base64 format and canonical padding prior to decoding.
- Ensures decoded bytes decode to valid UTF-8 text using strict UTF-8 checking.
- In case of invalid Base64, the selection remains untouched and an informative error message is displayed.
- Automatic Multi-Language Support (i18n / l10n): Extension commands, menus, and messages automatically adapt to your VS Code display language (English, French, Spanish, German, Japanese, Simplified Chinese).
- Multi-Cursor (Multi-Selection) Support: Transform multiple selections simultaneously across your document in a single atomic edit.
📖 Usage
1. Encode to Base64
- Select text in the active editor.
- Right-click on the selection.
- Hover over Base64 and click Encode to Base64 (or Encode en Base64 depending on your language).
- The selection is immediately replaced by its Base64 representation.
Example (Plain text):
Hello World
Select -> Right-click -> Base64 -> "Encode to Base64"
SGVsbG8gV29ybGQ=
Example (Programming code with quotes):
const user = "Houssam";
Select "Houssam" -> Right-click -> Base64 -> "Encode to Base64"
const user = "SG91c3NhbQ==";
2. Decode from Base64
- Select a Base64-encoded string in the editor.
- Right-click on the selection.
- Hover over Base64 and click Decode from Base64 (or Decode depuis Base64).
- The selection is replaced by the decoded UTF-8 text.
Example:
Qm9uam91ciDDqXTDqSDwn5GL
Select -> Right-click -> Base64 -> "Decode from Base64"
Bonjour été 👋
⌨️ VS Code Commands
| Command |
ID |
Description |
| Encode to Base64 |
base64.encode |
Encodes the selected text into Base64 |
| Decode from Base64 |
base64.decode |
Decodes the selected Base64 string into plain text |
Commands are also accessible anytime via the Command Palette (Ctrl+Shift+P / Cmd+Shift+P).
🛠️ Development & Testing
Prerequisites
Install Dependencies
npm install
Compile
npm run compile
Watch Mode
npm run watch
Run Automated Tests
npm test
Test Extension Locally
- Open this repository folder in VS Code.
- Press
F5 (or go to the Run and Debug tab and select Run Extension).
- A new VS Code window ("Extension Development Host") opens with the extension activated.
- Open or create a file, select any text, and test the right-click menu!
Package Extension (.vsix)
npx @vscode/vsce package
📂 Project Structure
base64-vscode-extension/
├── .vscode/
│ ├── launch.json # VS Code debug launcher (F5)
│ └── tasks.json # Build tasks (compile / watch)
├── l10n/ # Code localization bundles (en, fr, es, de, ja, zh-cn)
├── src/
│ ├── base64.ts # Pure Base64 logic (encode, decode, isValidBase64, quote parser)
│ ├── extension.ts # VS Code extension entry point & selection editing
│ └── test/
│ └── base64.test.ts# 34 comprehensive automated unit tests
├── icon.png # Official 256x256 extension icon
├── CHANGELOG.md # Version history and release notes
├── LICENSE # MIT License
├── package.json # Extension manifest, commands & menus
├── package.nls.*.json # Manifest localization files
├── tsconfig.json # TypeScript configuration
├── .vscodeignore # VSIX package file filter
└── README.md # Project documentation
📄 License
This project is licensed under the MIT License - © 2026 Houssam OUATMANI.
| |