/encode - Encode/Decode Data
Encode and decode data in various formats including Base64, URL encoding, and hex.
System Prompt
EXECUTION DIRECTIVE: When /encode is invoked, IMMEDIATELY process the encoding/decoding.
Usage
# Base64
/encode base64 "Hello World" # Encode to Base64
/encode base64 -d "SGVsbG8gV29ybGQ=" # Decode from Base64
# URL encoding
/encode url "hello world & more" # URL encode
/encode url -d "hello%20world" # URL decode
# Hex
/encode hex "Hello" # To hex
/encode hex -d "48656c6c6f" # From hex
# JSON escape
/encode json '{"key": "value"}' # Escape for JSON string
# File encoding
/encode base64 -f image.png # Encode file to Base64
Execution
~/.coditect/scripts/encode.sh base64 "text"
~/.coditect/scripts/encode.sh base64 -d "encoded"
~/.coditect/scripts/encode.sh url "text"
~/.coditect/scripts/encode.sh hex "text"
Encoding Types
| Type | Encode | Decode |
|---|---|---|
base64 | Text to Base64 | Base64 to text |
url | URL encode spaces/special | URL decode |
hex | Text to hexadecimal | Hex to text |
json | Escape for JSON string | Unescape JSON |
html | HTML entities | Decode entities |
Output Format
======================================================================
Encode/Decode Result
======================================================================
Input: Hello World
Type: base64 (encode)
Output: SGVsbG8gV29ybGQ=
[Copied to clipboard]
======================================================================
Examples
Base64 Encoding
$ /encode base64 "Hello World"
SGVsbG8gV29ybGQ=
$ /encode base64 -d "SGVsbG8gV29ybGQ="
Hello World
URL Encoding
$ /encode url "name=John Doe&city=New York"
name%3DJohn%20Doe%26city%3DNew%20York
$ /encode url -d "name%3DJohn%20Doe"
name=John Doe
Hex Encoding
$ /encode hex "ABC"
414243
$ /encode hex -d "414243"
ABC
Implementation
#!/bin/bash
case "$1" in
base64)
if [ "$2" = "-d" ]; then
echo "$3" | base64 -d
else
echo -n "$2" | base64
fi
;;
url)
if [ "$2" = "-d" ]; then
python3 -c "import urllib.parse; print(urllib.parse.unquote('$3'))"
else
python3 -c "import urllib.parse; print(urllib.parse.quote('$2'))"
fi
;;
esac
Related Commands
| Command | Purpose |
|---|---|
/uuid | Generate UUIDs |
/json-format | Format JSON |
Version: 1.0.0 Created: 2026-01-15 Author: CODITECT Team