# Base64 Text & File Encoder/Decoder — Language Guides, Use-Case Guides, Definitions, Conversions For the full tool, see: [https://capytoolkit.com/tools/developer/base64/](https://capytoolkit.com/tools/developer/base64/) ## Base64: Code Examples [Python base64](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-python): How to base64 encode and decode strings and files in Python using the base64 module. Standard and URL-safe variants, with examples. [JavaScript btoa/atob and Buffer](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-javascript): Base64 encoding in JavaScript using btoa/atob, Buffer (Node.js), and the modern Uint8Array approach. Handle Unicode correctly. [Java Base64 (java.util)](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-java): Java 8+ java.util.Base64 encoder and decoder. Standard, URL-safe, and MIME variants with examples for strings and files. [Bash base64 Command](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-bash): Base64 encoding and decoding in Bash using the base64 command. Encode files, strings, and pipe output. Linux, macOS, and WSL. [Go encoding/base64](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-go): Go encoding/base64 package: standard and URL-safe encoding, Raw (no padding), and streaming encoder/decoder for files. [TypeScript (Node.js and Deno)](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-typescript): Base64 encoding in TypeScript using Node.js Buffer, the browser TextEncoder pattern, and Deno encodeBase64. Type-safe examples with no external dependencies. [Rust base64 crate](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-rust): Rust Base64 encoding with the base64 crate. Standard and URL-safe engines, byte slice encoding, and String decoding with the Engine trait. [PHP base64_encode](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-php): PHP built-in base64_encode() and base64_decode() functions with examples for strings, files, and URL-safe encoding for JWT and OAuth. [C# Convert.ToBase64String](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-csharp): C# Base64 encoding using Convert.ToBase64String and Convert.FromBase64String. Covers byte arrays, strings, files, streaming, and URL-safe variants. [Ruby Base64 module](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-ruby): Ruby Base64 encoding using the standard library Base64 module. encode64, strict_encode64, urlsafe_encode64, and decode64 with string and file examples. [Swift Data.base64EncodedString](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-swift): Swift Base64 encoding using Data.base64EncodedString() and Data(base64Encoded:). Covers standard and URL-safe variants for iOS and macOS apps. [Kotlin Base64 (java.util.Base64)](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-kotlin): How to base64 encode and decode strings and files in Kotlin using java.util.Base64. Standard, URL-safe, and MIME variants with examples. [PowerShell Base64](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-powershell): How to base64 encode and decode strings and files in PowerShell using Convert.ToBase64String and System.Text.Encoding. Windows and cross-platform examples. [curl and CLI Basic Auth](https://capytoolkit.com/tools/developer/base64/code-examples/#base64-curl): How to use Base64 for Basic Auth in curl, encode credentials with base64 command, and build Authorization headers manually in shell scripts. ## Use-Case Guides [Embedding Images as Data URIs in HTML and CSS](https://capytoolkit.com/tools/developer/base64/data-uri-encoding/): Learn how to embed images, SVGs, and fonts as Base64 data URIs in HTML attributes and CSS. Includes format, size limits, and when to avoid inlining. [Building HTTP Basic Auth Headers with Base64](https://capytoolkit.com/tools/developer/base64/base64-basic-auth/): HTTP Basic Authentication encodes username:password in Base64 for the Authorization header. Learn the format, curl usage, and why HTTPS is required. [How JWT Tokens Use Base64url Encoding](https://capytoolkit.com/tools/developer/base64/base64-jwt-payload/): JWT tokens encode header and payload as Base64url without padding. Learn the structure, how to decode the claims, and why JWTs are not encrypted by default. [Base64 in Kubernetes Secrets](https://capytoolkit.com/tools/developer/base64/base64-kubernetes-secrets/): Kubernetes Secrets store values as Base64-encoded strings in YAML. Learn how to encode, decode, and manage secrets , and why Base64 is not encryption. [MIME Email Attachments and Base64 Encoding](https://capytoolkit.com/tools/developer/base64/base64-email-mime/): SMTP email encodes attachments as Base64 in MIME multipart messages. Learn the format, line length rules, charset headers, and common email encoding bugs. [Storing Binary Secrets in Environment Variables](https://capytoolkit.com/tools/developer/base64/base64-env-secrets/): Environment variables only hold text strings, but Base64 encoding lets you store binary secrets like TLS keys and certificates as env var values. Learn the pattern and risks. [Embedding Binary Data in JSON APIs](https://capytoolkit.com/tools/developer/base64/base64-binary-json/): JSON cannot represent raw binary data. Base64 encoding is the standard way to embed images, files, and binary fields in JSON API requests and responses. [URL-Safe Base64 vs Standard Base64](https://capytoolkit.com/tools/developer/base64/base64-url-safe/): URL-safe Base64 replaces + with - and / with _ so strings are safe in URLs, HTTP headers, and filenames. Learn when to use each variant and how to convert between them. [SSH Keys and PEM Certificates in Base64](https://capytoolkit.com/tools/developer/base64/base64-ssh-pem-keys/): SSH keys, TLS certificates, and PEM files wrap raw binary keys in Base64 between header and footer markers. Learn the format, how to decode keys, and common CI/CD patterns. ## Base64 Reference [What Is Base64 Encoding?](https://capytoolkit.com/tools/developer/base64/reference/#what-is-base64): Base64 encoding converts binary data into 64 printable ASCII characters. Learn how it works, where it is used, and why it is not encryption. [What Is URL-Safe Base64?](https://capytoolkit.com/tools/developer/base64/reference/#url-safe-base64): URL-safe Base64 replaces + with - and / with _ so encoded strings can be used in URLs and HTTP headers without percent-encoding. Used in JWT, OAuth, and PKCE. [What Is Padding in Base64?](https://capytoolkit.com/tools/developer/base64/reference/#base64-padding): Base64 padding adds = characters to align the output to a 4-character boundary. Learn when padding is required, when to strip it, and how to decode unpadded Base64. [Base64 vs Hex: Which Encoding to Use?](https://capytoolkit.com/tools/developer/base64/reference/#base64-vs-hex): Base64 encodes 3 bytes as 4 characters (33% overhead). Hex encodes 1 byte as 2 characters (100% overhead). Learn which to choose for APIs, hashes, keys, and data URIs. [What Is a Data URI?](https://capytoolkit.com/tools/developer/base64/reference/#what-is-a-data-uri): A data URI embeds file content directly in HTML or CSS using the data: scheme. Learn the format, size limits, use cases, and performance trade-offs. ## Base64 Text & File Encoder/Decoder: Conversions [bytes to Base64 characters](https://capytoolkit.com/tools/developer/base64/conversions/#bytes-to-base64-characters): Convert bytes to Base64 characters instantly. Uses the exact 4/3 Base64 expansion ratio. [Base64 characters to bytes](https://capytoolkit.com/tools/developer/base64/conversions/#base64-characters-to-bytes): Convert Base64 characters to bytes instantly. Uses the exact 4/3 Base64 expansion ratio. [kilobytes to Base64 kilobytes](https://capytoolkit.com/tools/developer/base64/conversions/#kilobytes-to-base64-kilobytes): Convert kilobytes to Base64 kilobytes instantly. Uses the exact 4/3 Base64 expansion ratio.