Guide d'Encodage & Décodage
Maîtrisez l'encodage et le décodage Base64, URL, HTML avec des exemples pratiques.
Encoding converts data from one representation to another for safe storage or transmission. Developers work with several encoding types daily — knowing when to use each prevents security vulnerabilities and data corruption.
Base64 Encoding
Converts binary data into printable ASCII using 64 characters. Used in email attachments, data URIs, JWT tokens, and Basic Auth headers.
- Output is ~33% larger than input (3 bytes → 4 characters)
- Ends with 1–2
=padding characters - NOT encryption — trivially reversible
btoa("Hello World") // → "SGVsbG8gV29ybGQ="
atob("SGVsbG8gV29ybGQ=") // → "Hello World" URL Encoding
Replaces unsafe URL characters with % + hex code. Spaces → %20, special chars like &, =, ? are encoded to prevent parsing ambiguity.
encodeURIComponent("Hello World!") // → "Hello%20World%21"
// Use encodeURIComponent for query param values
// Use encodeURI only for complete URLs HTML Entity Encoding
Prevents XSS by escaping HTML special characters:
&→&<→<>→>"→"
Frequently Asked Questions
Is Base64 safe for passwords?
No. Use bcrypt or Argon2 for passwords, AES for sensitive data. Base64 is not encryption.
When to use URL-safe Base64?
When the value appears in URLs or HTTP headers — JWT tokens use URL-safe Base64 (base64url) by spec.
What encoding should I always use for web?
Always UTF-8. It represents all Unicode characters and is backward-compatible with ASCII.
Related Tools
Formateur JSON
Embellissez et formatez du JSON avec coloration syntaxique.
Validateur JSON
Validez la syntaxe JSON instantanément avec des messages d'erreur détaillés.
Minificateur JSON
Minifiez le JSON en supprimant les espaces et le formatage.
JSON vers CSV
Convertissez des tableaux JSON en format CSV pour tableurs.
JSON vers XML
Convertissez des données JSON en format XML valide instantanément.
Comparaison JSON
Comparez deux objets JSON et mettez en évidence leurs différences.