玲珑盒,一款工具集 - A collection of useful utility tools for developers.
brew tap wgzhao/tap
brew install lingboxDownloads the latest precompiled binary for your OS and architecture (no Go required):
curl -fsSL https://raw.githubusercontent.com/wgzhao/ling-box/master/install.sh | bashCustomize with --install-dir <dir> (or LINGBOX_INSTALL_DIR), or pin a
version with LINGBOX_VERSION (e.g. LINGBOX_VERSION=0.5.0). The binary is
SHA-256 verified against the release digest. The installer also sets up the
lb alias and tab completion in your shell (skip with
LINGBOX_NO_SHELL_SETUP=1).
Requires Go 1.26 or higher. See Building below.
For Homebrew or source installs, run lingbox shell install once to add the
lb alias and tab completion (see Shell Integration).
- URL Encoding/Decoding: Encode and decode URL strings
- Base64 Encoding/Decoding: Encode and decode Base64 strings (supports URL-safe mode)
- Hashing & HMAC: Compute MD5, SHA-1/2, SM3, CRC32 and HMAC digests of strings, files, or stdin (
hash) - JWT Decoding: Decode header and claims, check time claims, and verify HS/RS/PS/ES signatures (
jwt) - One-Time Passwords: Generate TOTP/HOTP codes from base32 secrets or
otpauth://URIs (otp) - BCrypt Password Hashing: Generate and verify bcrypt password hashes
- QR Code Generation: Generate QR codes as PNG, JPG, or GIF images
- QR Code Decoding: Extract text from PNG, JPG, or GIF QR images (
qrdecode) - Password Generation: Generate secure random passwords with customizable options
- UUID Generation: Generate UUIDs (v1, v4, v7) in bulk
- Format Conversion: Convert between JSON, YAML, CSV, and Markdown (pandoc-style
-i/-o/-t) - JSON Formatting & Validation: Re-indent JSON and validate its syntax (
json format,json verify) - Unicode Encoding/Decoding: Encode text to \uXXXX escapes and decode back
- Text Transforms: Case conversion, HTML/JSON escapes, full/half-width, and text statistics (
text) - Chinese Numerals: Convert Arabic ↔ Chinese numerals, lowercase or financial uppercase (
cnnum;rmbalias defaults to uppercase) - Chinese ID Card: Validate 15/18-digit IDs and generate synthetic test numbers (
idcard) - Color Conversion: Convert between Hex, RGB, HSL, and named colors
- BMI Calculator: Calculate Body Mass Index from height and weight
- Number Base Conversion: Convert between binary, octal, decimal, and hexadecimal
- Date & Timestamp Tools: Add/subtract days, diff dates, and convert Unix/RFC3339/timezones (
date add|diff|ts) - Chinese Lunar Calendar: Gregorian ↔ lunar conversion, leap months, 24 solar terms, sexagenary cycle, zodiac (
date lunar) - Cron Expressions: Explain schedules and list upcoming run times (
cron) - Terminal Image Display: Display images directly in the terminal (iTerm2/Kitty/half-block/ASCII)
- SSL Certificate Inspection: Inspect X.509 certificates (subject, issuer, key strength, validity, extensions)
- SSL Host Scanning: Scan a host's TLS protocols, cipher suites with security ratings, and certificate trust
- License Plate Lookup: Query Chinese license plate codes by province (
plate) - IPv4 Subnet Calculator: Calculate networks, broadcast, wildcard masks, and host ranges; sub-/supernets, deaggregation, and splitting (
ipcalc) - Temporary Web Server: Serve a directory over HTTP with python
http.server-style listings and logs (webserver) - DBF File Reading: Read dBase/FoxPro tables (
dbf info|view|export), with GBK/GB18030/Big5 decoding and .fpt/.dbt memo support - IP Geolocation: Look up the region and ISP of IPv4 addresses from the qqwry.dat database (
ipgeo); the database is downloaded on first use and cached
- Go 1.26 or higher
go build -ldflags "-s -w" -trimpath -o lingbox ../lingbox <command> [options]lingbox exposes its text tools to launchers through a stable JSON contract. Alfred is the first adapter (macOS + Powerpack):
# Tool metadata any launcher can consume
lingbox tools --json
# Machine-readable results
lingbox ipcalc --json -- 10.0.0.0/8
# Alfred Script Filter
lingbox launcher alfred --query "ip 10.0.0.0/8"Download lingbox.alfredworkflow from the releases page and double-click it,
or build it from contrib/alfred. The keyword is
lb: lb uuid, lb ip 10.0.0.0/8, lb b64 hello, lb ssl example.com.
The workflow also provides Alfred File Actions for .dbf (info/export),
JSON/YAML/CSV/Markdown conversion and images; ssl and ipgeo run in the
background and refresh automatically. The workflow searches PATH and the
usual Homebrew/go install locations; set LINGBOX_BIN if your binary lives
elsewhere.
A uTools plugin using the same launcher JSON contract lives in
contrib/utools.
The contract is launcher-independent; uTools and Raycast adapters can reuse
lingbox tools --json without touching the tools.
./lingbox --help# Encode a URL string
./lingbox url -e 'hello world'
# Output: hello+world
# Decode a URL string
./lingbox url -d 'hello+world'
# Output: hello world# Encode a string to Base64
./lingbox base64 -e 'Hello World'
# Output: SGVsbG8gV29ybGQ=
# Decode a Base64 string
./lingbox base64 -d 'SGVsbG8gV29ybGQ='
# Output: Hello World
# Use URL-safe Base64 (flag placement matters: -u before -e)
./lingbox base64 -u -e 'test+/string'# Default: SHA-256
./lingbox hash abc
# Output: sha256 ba7816bf8f01cfea414140de5dae2223...
# Several algorithms at once
./lingbox hash -a md5,sm3 abc
# Hash a file (streamed, not read into memory)
./lingbox hash -f archive.zip -a sha256
# HMAC (key required)
./lingbox hash -a hmac-sha256 -k secret 'message'
# Read from stdin
echo -n abc | ./lingbox hash -a sha1# Decode the header and payload without verifying the signature
./lingbox jwt 'eyJhbGciOiJIUzI1NiIs...'
# Verify an HS256 token
./lingbox jwt --secret mysecret 'eyJhbGciOiJIUzI1NiIs...'
# Verify RS*/PS*/ES* with a PEM public key, certificate, or private key
./lingbox jwt --public-key public.pem 'eyJhbGciOiJSUzI1NiIs...'
# Read the token from stdin
cat token.txt | ./lingbox jwt --secret mysecret# Current TOTP code (6 digits, 30-second period)
./lingbox otp JBSWY3DPEHPK3PXP
# 8 digits with a 60-second period
./lingbox otp -d 8 --period 60 JBSWY3DPEHPK3PXP
# Deterministic TOTP (Unix seconds)
./lingbox otp --at 59 -d 8 GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ
# Output: 94287082
# HOTP
./lingbox otp --counter 5 JBSWY3DPEHPK3PXP
# otpauth:// URI (e.g. decoded from an authenticator QR code)
./lingbox otp 'otpauth://totp/ACME:alice?secret=JBSWY3DPEHPK3PXP&issuer=ACME'# Generate a bcrypt hash
./lingbox bcrypt -g mypassword
# Output: $2a$12$...
# Verify a password against a hash
./lingbox bcrypt -v mypassword '$2a$12$...'# Generate a QR code (default: qrcode.png, 300x300)
./lingbox qrcode 'https://example.com'
# Custom output file and size
./lingbox qrcode 'Hello World' -o mycode.png -s 500
# Different format
./lingbox qrcode 'Test' -o mycode.jpg -f JPG# Decode a QR code image
./lingbox qrdecode qrcode.png
# Decode from stdin
cat qrcode.png | ./lingbox qrdecode# Generate a 16-character password (default)
./lingbox password
# Generate a 24-character password
./lingbox password -l 24
# Generate multiple passwords
./lingbox password -c 5
# Generate digits-only password
./lingbox password -d
# Generate uppercase-only password
./lingbox password -u
# Generate password without special characters
./lingbox password -n# Generate a v4 UUID (default)
./lingbox uuid
# Generate 5 UUIDs
./lingbox uuid -n 5
# Generate UUID v7 (time-ordered, sortable)
./lingbox uuid -t v7
# Generate UUID v1 (time-based)
./lingbox uuid -t v1Convert between JSON, YAML, CSV, and Markdown with a pandoc-style -i/-o/-t
interface. The input format is read from the -i file extension (or detected
from stdin); the target format comes from -t, or is guessed from the -o
extension when -t is omitted.
Input formats: json, yaml/yml, csv. Output formats: json, yaml,
csv, markdown.
CSV output requires an array of objects (first row = header) or an array of scalar values. Markdown output also accepts a scalar array (bullet list) and a top-level object (key/value table). Nested objects and arrays inside cells are encoded as compact JSON strings. CSV input uses the first row as the header; cells stay strings (no type inference).
# Convert JSON to YAML (target format guessed from -o extension)
./lingbox convert -i data.json -o data.yaml
# CSV to Markdown
./lingbox convert -i data.csv -t markdown
# JSON to CSV
./lingbox convert -i data.json -o data.csv
# From stdin (format auto-detected: JSON, then YAML, then CSV)
cat data.json | ./lingbox convert -t yaml
curl -s https://api.example.com/data | ./lingbox convert -o out.yaml
# Markdown table output
./lingbox convert -i data.yaml -o table.md# Format (re-indent) JSON; key order is preserved
./lingbox json format data.json
cat data.json | ./lingbox json format --indent 4
# Sort keys and/or collapse to a single line
cat data.json | ./lingbox json format --sort-keys --compact
# Validate JSON syntax (exits 1 on failure with line/column)
./lingbox json verify data.json
cat data.json | ./lingbox json verify -q # silent on success# Add or subtract days
./lingbox date add 2026-01-01 10
./lingbox date add 2026-01-01 -- -30
# Difference between two dates or datetimes
./lingbox date diff 2026-01-01 2026-07-26
./lingbox date diff "2026-01-01 12:00:00" "2026-01-02 14:30:00"
# Unix seconds or milliseconds (auto-detected) in any timezone
./lingbox date ts 1735689600
./lingbox date ts 1735689600000 --tz UTC
# RFC3339 or local date strings
./lingbox date ts --tz Asia/Shanghai '2025-01-01 08:00:00'
# Current time
./lingbox date ts# Solar to lunar (default: today)
./lingbox date lunar 2025-01-29
# Lunar: 2025年正月初一 / 乙巳年 / 蛇
# Lunar to solar; --leap selects the leap month
./lingbox date lunar --lunar 2025-01-01
./lingbox date lunar --lunar 2025-06-01 --leap
# The 24 solar terms of a year
./lingbox date lunar --terms --year 2025
# Machine-readable details
./lingbox date lunar --json 2025-01-29Supported year range: 1900–2100.
# Explain the expression and list the next 5 runs
./lingbox cron '*/5 * * * *'
./lingbox cron '0 9 * * MON-FRI' -n 10
# Six-field expressions include a seconds field
./lingbox cron '30 * * * * *'
# Macros work too
./lingbox cron '@daily'
# Deterministic output for scheduling checks
./lingbox cron '0 0 1 * *' --from 2026-01-01T00:00:00Z --tz UTC -n 3# Encode Chinese characters to \uXXXX
./lingbox unicode -e '你好世界'
# Output: 你好世界
# Decode \uXXXX back to text
./lingbox unicode -d '你好世界'
# Output: 你好世界
# Auto-detect mode (encodes if plain text, decodes if \uXXXX)
./lingbox unicode '你好'# Case conversions
./lingbox text snake "Hello World" # hello_world
./lingbox text camel hello_world # helloWorld
./lingbox text kebab "XMLHttpRequest" # xml-http-request
./lingbox text slug "Hello, World!" # hello-world
# Escapes
./lingbox text html-encode '<a href="x">'
./lingbox text json-unescape 'hello\nworld'
./lingbox text fullwidth ABC123 # ABC123
# Statistics: characters, bytes, words, lines, CJK, reading time
./lingbox text stats "Hello 世界"
# Read from stdin
echo 'Hello World' | ./lingbox text snake# Lowercase Chinese numerals (default)
./lingbox cnnum 123 # 一百二十三
./lingbox cnnum 100000001 # 一亿零一
# Financial uppercase form
./lingbox cnnum --style upper 123 # 壹佰贰拾叁
./lingbox rmb 123 # 壹佰贰拾叁 (rmb alias default)
# Auto-detect the reverse direction
./lingbox cnnum 壹佰贰拾叁 # 123
./lingbox cnnum 一万亿 # 1000000000000
# Decimals and negatives
./lingbox cnnum -12.30 # 负十二点三零
./lingbox cnnum 零点零五 # 0.05
# From stdin
echo 123 | ./lingbox cnnum# Validate 18-digit and 15-digit numbers
./lingbox idcard validate 11010519491231002X
./lingbox idcard validate 110105491231002
# Strict mode rejects unknown/historical region codes
./lingbox idcard validate --strict 11010519491231002X
# Generate synthetic test numbers
./lingbox idcard generate
./lingbox idcard generate --region 310104 --birth 1985-06-15 --gender female -n 5
./lingbox idcard generate --jsonValidation covers format, birth date, gender, checksum, and the region name.
Region data is embedded (current county-level codes, derived from
modood/Administrative-divisions-of-China,
WTFPL), so old IDs using historical divisions produce a warning unless
--strict is used.
Generated numbers are synthetic and intended for form testing only. They may coincidentally match a real person's number; do not use them as a real identity.
# Named color
./lingbox color 'red'
# Output: Hex, RGB, HSL, and name
# Hex input
./lingbox color '#FF0000'
# RGB input
./lingbox color 'rgb(255, 0, 0)'
# HSL input
./lingbox color 'hsl(0, 100%, 50%)'
# Multi-word named color
./lingbox color 'dark gray'
./lingbox color 'light yellow'Display images directly in the terminal. Default renderer is OSC 1337 (iTerm2 protocol), which produces lossless output and is supported by iTerm2, WezTerm, Warp, kaku, kitty (compat mode), VS Code terminal, and many others.
# Display an image (auto-detect best renderer)
./lingbox imgcat photo.jpg
# Specify output width in character columns
./lingbox imgcat photo.png -w 60
# Force a specific renderer
./lingbox imgcat photo.jpg -r halfblock # ANSI ▀ blocks (universal)
./lingbox imgcat photo.jpg -r iterm2 # OSC 1337 lossless (default)
./lingbox imgcat photo.jpg -r kitty # Kitty native protocol
./lingbox imgcat photo.jpg -r ascii # Grayscale ASCII art
# Read from stdin
cat photo.png | ./lingbox imgcat
# Browse multiple images interactively (arrows/space for next, q to quit)
./lingbox imgcat photo1.jpg photo2.jpg photo3.png
# Glob patterns are expanded automatically (useful in quoted arguments)
./lingbox imgcat "875*.png"
./lingbox imgcat photo1.jpg "screenshot-*.png"
Parse and display detailed information about X.509 certificates: subject and issuer, signature algorithm, public key and key strength, validity period (including expired status), and extensions (SAN, key usages, SKI/AKI, OCSP, CRL, policies).
# From a file (PEM or DER .crt)
./lingbox ssl cert server.crt
./lingbox ssl cert -f fullchain.pem
# Inline PEM content (single-line with \n escapes also works)
./lingbox ssl cert '-----BEGIN CERTIFICATE-----...'
# From stdin
cat cert.pem | ./lingbox ssl certConnect to a host and report the supported TLS protocol versions, the cipher suites accepted per version (with INSECURE/WEAK ratings in red/yellow), and the presented certificate's validity, trust status, and hostname match.
# Default port 443
./lingbox ssl host www.baidu.com
# Explicit port
./lingbox ssl host https://www.baidu.com:8443
./lingbox ssl host example.com:8443
# Per-handshake timeout (default 5s)
./lingbox ssl host www.baidu.com -t 10
# Quiet mode: no progress display (for batch/scripted use)
./lingbox ssl host www.baidu.com -qProgress is shown by default on a terminal and written to stderr, so a piped/redirected stdout always contains only the report. It is suppressed automatically when stderr is not a terminal.
Notes: SSL 3.0 cannot be probed (Go's TLS client does not implement it), and TLS 1.3 cipher suites are not individually negotiable, so they are reported as a group.
Query Chinese license plate codes by province or municipality. The argument accepts the one-character abbreviation (湘), the full name (湖南省), or the name without its administrative suffix (湖南).
# Query one province
./lingbox plate 湘
./lingbox plate 湖南省
./lingbox plate 湖南
# List all 31 provinces, paged (Enter: next page, q: quit)
./lingbox plate
# More provinces per page (interactive mode)
./lingbox plate -n 10
# Non-interactive: piped or redirected output prints everything at once
./lingbox plate | grep 湘Port of Krischan Jodies' ipcalc (v0.41). Takes an IP address and netmask and calculates the resulting broadcast, network, Cisco wildcard mask, and host range, presenting the results as easy-to-understand binary values. By giving a second netmask you can design sub- and supernetworks.
# Basic calculation (netmask defaults to /24 when omitted)
./lingbox ipcalc 192.168.0.1/24
# Dotted or wildcard (inverse) netmasks are recognized
./lingbox ipcalc 192.168.0.1/255.255.128.0
./lingbox ipcalc 192.168.0.1 0.0.63.255
# Subnets after transition (second netmask > first)
./lingbox ipcalc 192.168.0.1 255.255.255.0 255.255.255.128
# Supernet (second netmask < first)
./lingbox ipcalc 10.0.0.1 255.255.255.0 255.255.0.0
# Deaggregate an address range into CIDR blocks
./lingbox ipcalc 192.168.1.10 - 192.168.2.5
./lingbox ipcalc 192.168.1.10 192.168.2.5 -r
# Split a network into subnets sized for the given host counts
./lingbox ipcalc 10.0.0.0/24 -s 100 50 25
# Print the natural class bit-count mask only
./lingbox ipcalc -c 192.168.0.1 # -> 24
# No binary display / no colors
./lingbox ipcalc 192.168.0.1/24 -b
./lingbox ipcalc 192.168.0.1/24 -nColors are enabled automatically on a terminal (respecting NO_COLOR) and can
be disabled with -n. The original's two stray debug lines ("WILDCARD" and
"INVALID NETMASK") are intentionally not reproduced.
Serve the current directory over HTTP with the same interface as
python3 -m http.server: identical startup message, request log format,
directory listings, and error pages.
# Serve ./ on port 8000 (default)
./lingbox webserver
# Serve a specific directory on a specific port
./lingbox webserver 8080
./lingbox webserver -d ~/public
# Bind to localhost only
./lingbox webserver -b 127.0.0.1
# Port 0 picks a free port (shown in the startup message)
./lingbox webserver 0Serves files with MIME type detection, index.html support, percent-decoded paths, and directory listings. Path traversal attempts ("..") are blocked. Request logs go to stderr in python's format; Ctrl-C stops the server gracefully ("Keyboard interrupt received, exiting.").
Read dBase / FoxPro database table files (.dbf), including the common field types (C/N/F/D/L/M/I/T/Y/B) and memo files (.fpt/.dbt).
# Show the file header, encoding, and fields
./lingbox dbf info 客户.dbf
# Browse records as an aligned table (CJK-aware)
./lingbox dbf view 客户.dbf -n 10
# Deleted records are hidden by default; show them with a * marker
./lingbox dbf view 客户.dbf --include-deleted
# Force an encoding (auto-detected from the language driver ID,
# defaulting to GBK)
./lingbox dbf view 客户.dbf -e gbk
# Export to CSV or typed JSON
./lingbox dbf export 客户.dbf -o 客户.csv
./lingbox dbf export 客户.dbf --jsonText encoding is auto-detected from the language driver ID (0x4D/0x7A = GBK) and defaults to GBK when unset. Encrypted tables (encryption flag set) are refused. Microsoft Access (.mdb/.accdb) is a different format and is not supported.
Look up the region and ISP of IPv4 addresses using the qqwry.dat database (纯真 IP 库), mirrored from metowolf/qqwry.dat (updated weekly).
The ~27 MB database is downloaded on first use into the user cache directory and reused offline afterwards:
| Platform | Default database path |
|---|---|
| macOS | ~/Library/Caches/ling-box/qqwry.dat |
| Linux | ~/.cache/ling-box/qqwry.dat (or $XDG_CACHE_HOME/ling-box) |
| Windows | %LocalAppData%\ling-box\qqwry.dat |
Both the modern CZDB-rebuilt layout and the classic qqwry.dat layout are
supported, so a custom database file can be used with --db.
# Single lookup (downloads the database on first use)
./lingbox ipgeo 8.8.8.8
# Multiple addresses
./lingbox ipgeo 114.114.114.114 223.5.5.5
# JSON output
./lingbox ipgeo --json 8.8.8.8
# Force a database update
./lingbox ipgeo --update 8.8.8.8
# Use a custom database file
./lingbox ipgeo --db /path/to/qqwry.dat 8.8.8.8lingbox shell install adds an lb alias for lingbox and loads tab
completion in your login shell's startup file (~/.bashrc, ~/.zshrc, or
~/.config/fish/config.fish). The install script does this automatically; for
Homebrew or manual installs, run it once yourself:
lingbox shell installThe snippet is written between marker comments, so running it again after an
upgrade updates it in place instead of adding a duplicate copy. Use
--dry-run to preview the result, --shell bash|zsh|fish to override shell
detection, --rc <file> to target a specific file, and
lingbox shell uninstall to remove it.
If you manage your rc files yourself, completion is also available directly (Cobra generates it):
# Bash
source <(lingbox completion bash)
# Zsh (after compinit has run)
source <(lingbox completion zsh)
# Fish
lingbox completion fish | source
# PowerShell
lingbox completion powershell | Out-String | Invoke-ExpressionAfter enabling, type lb con<Tab> to auto-complete to convert.
This tool is written in pure Go (no cgo), so it compiles to a single, static self-contained binary with no external library dependencies. It builds out-of-the-box for any platform:
- Windows
- macOS
- Linux
To create a new release, tag the commit and push:
git tag v1.0.0
git push origin v1.0.0This will automatically trigger GitHub Actions to:
- Build native binaries for Linux (x86-64, ARM64), Windows (x86-64), and macOS (x86-64, ARM64)
- Generate release notes from commits between tags
- Create a GitHub release with all binaries attached
| Command | Description | Example |
|---|---|---|
url |
URL encode/decode | url -e 'hello world' |
base64 |
Base64 encode/decode | base64 -e 'Hello' |
hash |
Hash/HMAC (md5, sha*, sm3, crc32) | hash -a sha256 abc |
jwt |
JWT decode and verification | jwt --secret s <token> |
otp |
TOTP/HOTP generation | otp JBSWY3DPEHPK3PXP |
bcrypt |
Password hashing | bcrypt -g mypass |
qrcode |
QR code generation | qrcode 'text' -o qr.png |
qrdecode |
QR code decoding | qrdecode qr.png |
password |
Password generator | password -l 24 -c 5 |
uuid |
UUID generation | uuid -n 5 -t v7 |
convert |
Format conversion (JSON/YAML/CSV/Markdown) | convert -i data.json -o data.yaml |
json format |
Re-indent JSON | json format data.json |
json verify |
Validate JSON syntax | json verify data.json |
unicode |
Unicode encoder/decoder | unicode -e '你好' |
text |
Text case/escape/stats | text snake 'Hello World' |
cnnum |
Chinese numeral converter | cnnum 123 / rmb 123 |
idcard validate |
ID card validation | idcard validate 11010519491231002X |
idcard generate |
Synthetic test IDs | idcard generate -n 3 |
color |
Color converter | color '#FF0000' |
bmi |
BMI calculator | bmi 170 65 |
base |
Base converter | base FF -f hex |
date |
Date calculator | date diff 2026-01-01 2026-07-26 |
date ts |
Timestamp/timezone conversion | date ts 1735689600 |
date lunar |
Lunar calendar conversion | date lunar 2025-01-29 |
cron |
Cron explainer and next runs | cron '*/5 * * * *' |
imgcat |
Terminal image display | imgcat photo.jpg |
ssl |
SSL certificate inspection | ssl cert server.crt |
ssl host |
TLS host scanning | ssl host www.baidu.com |
plate |
License plate lookup | plate 湘 |
ipcalc |
IPv4 subnet calculator | ipcalc 192.168.0.1/24 |
webserver |
Temporary HTTP server | webserver -d . 8080 |
dbf |
dBase/FoxPro table reader | dbf view 客户.dbf |
ipgeo |
IP geolocation lookup (qqwry.dat) | ipgeo 8.8.8.8 |
Full help: lingbox <command> --help
Apache License 2.0