Base32 Encoder / Decoder
テキストをRFC 4648準拠のBase32にエンコード・デコードします。全てブラウザ内で処理。
How to Use the Base32 Encoder / Decoder
This free online Base32 tool converts text to RFC 4648 Base32 and back. Choose "エンコード" (Encode) or "デコード" (Decode), enter your text, and click the button. UTF-8 input is fully supported, and padding (=) is added or handled automatically — everything runs locally in your browser.
What is Base32?
Base32 is a binary-to-text encoding defined in RFC 4648. It represents binary data using only 32 symbols — the uppercase letters A–Z and the digits 2–7 — deliberately excluding characters that are easy to confuse when handwritten or read aloud, such as 0/O and 1/I/L. Because it never mixes uppercase and lowercase meaningfully, Base32 output survives case-insensitive systems (some filesystems, DNS labels) that would corrupt Base64.
Base32 vs Base64
Base64 packs data more efficiently (about 133% of the original size, using 64 symbols) and is the better default for web contexts like data URIs or JSON payloads. Base32 trades efficiency (about 160% of the original size) for readability and case-insensitivity, which is why it is the standard encoding for values people may need to type by hand — most notably TOTP secret keys.
Base32 and TOTP (Google Authenticator)
RFC 6238 Time-based One-Time Password (TOTP) secrets — the kind used by Google Authenticator, Authy, and other 2FA apps — are encoded as Base32 by convention. When an app shows you a "can't scan the QR code? enter this key manually" screen, that string is Base32. This tool lets you inspect or construct such values, though you should never paste a real, active 2FA secret into any online tool.
Base32エンコード・デコードツールについて
このツールはRFC 4648準拠のBase32形式でテキストをエンコード・デコードします。UTF-8に完全対応しており、全ての処理はブラウザ内で完結するためデータがサーバーに送信されることはありません。Base32はA-Zと2-7の32文字だけを使うため、0とO、1とIとLのような紛らわしい文字を含まず、大文字小文字を区別しない環境でも安全に扱えます。
既存のBase64 Encoder / Decoderが64種類の文字でよりコンパクトに変換するのに対し、本ページは「大文字のみ・誤読しにくい」という特性が必要な場面(TOTPシークレットキーなど)に特化した変換を提供します。
実務での活用例
1. TOTP(2段階認証)シークレットキーの検証
自作の認証システムでTOTPを実装する際、生成したシークレットキーが正しいBase32文字列になっているか、あるいはBase32文字列から元のバイト列(ランダムシード)を復元して桁数を確認する、といったデバッグに使えます。実際に稼働中のアカウントのシークレットキーを外部ツールに貼り付けるのは避け、テスト用の値のみで確認してください。
2. 大文字小文字を区別しないシステム向けの識別子生成
一部のファイルシステムやDNSラベル、Windows環境など大文字小文字を区別しない(case-insensitive)システム間でデータをやり取りする場合、Base64だと大文字小文字の違いで値が壊れる可能性があります。Base32ならその心配がありません。
3. 手入力・読み上げが必要なコード体系の検討
リカバリーコードやライセンスキーなど、人が目で見て手入力する可能性がある文字列を設計する際、Base32の「紛らわしい文字を含まない」性質は入力ミスを減らすのに役立ちます。
よくあるエラーと対処 / Common Errors and Fixes
Base32デコードで遭遇しやすいエラーパターンです。
Patterns commonly seen when decoding Base32.
| エラー / Error | 原因 / Cause | 対処 / Fix |
|---|---|---|
| 無効なBase32文字 Invalid Base32 character | 0, 1, 8, 9 や小文字・記号が混入(Base32はA-Zと2-7のみ) Characters outside A-Z/2-7, such as 0, 1, 8, 9 | 使用可能な32文字(A-Z, 2-7)のみか確認する Verify only A-Z and 2-7 are present |
| デコード結果が文字化けする Decoded text is garbled | バイト列がUTF-8として不正(バイナリデータ、または別エンコーディング) The bytes are not valid UTF-8 — binary data or a different encoding | 元データの形式を確認。テキスト以外はバイト列のまま扱う Confirm the source format; treat non-text data as raw bytes |
| パディング(=)ありなしで結果が変わらないか不安 Unsure if padding affects the result | 本ツールはデコード時にパディングの有無を問わず処理する This tool accepts input with or without padding | そのまま貼り付けて問題なし。エンコード結果は常にパディング付き Paste as-is; encoded output always includes padding |
| Base64の文字列を貼ったらエラーになる Pasting a Base64 string causes an error | Base64は0-9や小文字、+/を含み、Base32のアルファベットと異なる Base64 uses digits, lowercase, and +/, which Base32 rejects | Base64 Encoder / Decoderを使用する Use the Base64 tool instead |
言語別コード例 / Code Examples by Language
JavaScript (RFC 4648)
const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
function base32Encode(bytes) {
let bits = "";
for (const b of bytes) bits += b.toString(2).padStart(8, "0");
let out = "";
for (let i = 0; i < bits.length; i += 5) {
out += ALPHABET[parseInt(bits.slice(i, i + 5).padEnd(5, "0"), 2)];
}
return out + "=".repeat((8 - (out.length % 8)) % 8);
}Python
import base64
# Encode
b32 = base64.b32encode("Hello".encode("utf-8")).decode("ascii")
# Decode
text = base64.b32decode(b32).decode("utf-8")Shell
# Encode (GNU coreutils)
echo -n "Hello" | base32
# Decode
echo "JBSWY3DP" | base32 -dGo
import "encoding/base32"
b32 := base32.StdEncoding.EncodeToString([]byte("Hello"))
data, _ := base32.StdEncoding.DecodeString(b32)Before / After 実例 / Before & After
例1: シンプルな文字列のエンコード / Encode a simple string
Hello → JBSWY3DP例2: 日本語 UTF-8 / Japanese UTF-8
こんにちは → 4OAZHY4CSPRYDK7DQGQ6HANP例3: TOTPシークレットキー形式 / A typical TOTP secret key
JBSWY3DPEHPK3PXP ← Base32(パディングなし)。認証アプリの手動入力欄に貼るのはこの形式TOTPシークレットは32文字前後のBase32(パディング省略)が一般的です。
TOTP secrets are typically an unpadded Base32 string around 32 characters long.
Why browser-only? / なぜブラウザ完結か
Base32 is the encoding behind TOTP two-factor authentication secrets — arguably some of the most sensitive short strings that exist, since anyone holding one can generate valid login codes for an account. A server-side encoder would see that value in its request body and access logs. This tool performs every step of the encode/decode process — bit packing, alphabet lookup, padding — in plain JavaScript inside your browser tab. No network request is made; verify it yourself in DevTools → Network. As a rule, never paste a live, in-use 2FA secret into any web tool, including this one — treat this page as a format-inspection tool for test values, not a place to process production credentials.
Base32はTOTP二要素認証のシークレットキーに使われる形式で、保持していれば有効なログインコードを生成できてしまう、極めて機密性の高い短い文字列です。サーバー型の変換ツールはその値をリクエストボディやアクセスログに残す可能性があります。本ツールはビット処理・アルファベット変換・パディングのすべてをブラウザ内のJavaScriptだけで実行し、ネットワーク通信を一切行いません。稼働中の2FAシークレットは本ツールを含むいかなるWebツールにも貼り付けず、テスト用途に留めることを推奨します。
関連ツール / Related Tools
開発をもっと効率的に
PR