Base64 in Golang: Encoding and Decoding Byte Slices with encoding/base64
Practical Go recipes for standard and URL-safe Base64 encoding using Go standard library encoding/base64 package.
Try Toolstack's Base64 Encoder & Decoder
Free, instantaneous, and processes 100% locally in your browser.
Go provides built-in, highly optimized Base64 algorithms in the standard `encoding/base64` package.
Standard Encoding in Go
package main
import (
"encoding/base64"
"fmt"
)
func main() {
data := []byte("Hello Golang!")
encoded := base64.StdEncoding.EncodeToString(data)
fmt.Println(encoded) // SGVsbG8gR29sYW5nIQ==
decoded, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
panic(err)
}
fmt.Println(string(decoded))
}
URL-Safe Without Padding in Go
For JWT tokens and web queries, use `base64.RawURLEncoding`: ```go urlSafe := base64.RawURLEncoding.EncodeToString([]byte("token_payload")) ```
More Guides in Base64 & Encoding
Explore More Free Tools on Toolstack
Client-side developer utilities, image converters, calculators, and educational engineering guides.
Bulk CSV Data Cleaner
Clean, deduplicate, filter, reorder columns, and sanitize CSV datasets 100% in browser.
Redirect Checker & GSC Analyzer
Audit HTTP redirect chains (301, 302, 308), loops, and Google Search Console exports.
Bulk URL Status Checker
Batch check HTTP status codes (200, 301, 404, 500), latency, and hops in bulk.
Time Zone Meeting Planner
Find overlapping working hours across 2 to 10 cities and copy meeting invites instantly.
Word Counter
Count words, characters with/without spaces, sentences, and paragraphs in real time with reading speed metrics.
PDF Compressor
Reduce PDF document file size directly in your browser with zero server uploads.