Base64URL in cookies: safe decode workflow and common pitfalls

TL;DR: Validate locally, fix the first real error, validate again (no upload).

Handle Base64URL in cookies: safe decode workflow and common pitfalls with a repeatable Base64URL workflow: normalize alphabet, fix padding, decode locally, and validate.

Base64URL quick map

RuleBase64Base64URL
Alphabet+, /-, _
PaddingOften has =Often omits =
Typical useGeneral binary transportURLs, JWT segments

Focus for this query

  • If this value came from a URL parameter, URL-decode first, then normalize Base64URL.

Safe decode workflow

  1. Remove whitespace/newlines.
  2. Normalize alphabet: -+, _/.
  3. Add padding so length % 4 == 0.
  4. Decode locally and validate output shape (JSON/text/binary).

Runtime snippet (generic)

function base64urlToBase64(input) {
  const s = String(input || '').replace(/\s+/g, '').replace(/-/g, '+').replace(/_/g, '/');
  return s + '='.repeat((4 - (s.length % 4)) % 4);
}

const b64 = base64urlToBase64(token);
const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
const text = new TextDecoder().decode(bytes);
console.log(text);

Frequent failures

Privacy guardrail

Base64/Base64URL strings can still contain secrets. Decode locally, redact sensitive fields, and only then share snippets.

FAQ

Is anything uploaded to a server? No. All processing happens locally in your browser. Files are never uploaded.

What is the recommended workflow? Validate the input, fix the first real issue, validate again, then export/convert. This avoids compounding errors.

Privacy & Security
All processing happens locally in your browser. Files are never uploaded.

Quick fix checklist

  • Reproduce the error on a minimal input.
  • Check type/format and field mapping.
  • Apply the smallest safe fix.
  • Validate on production-like payload.

Next pages to check

Closest crawled pages without impressions yet. Added to speed first-impression conversion.

neighbor csharp csharp newtonsoft error converting infinity system int32 user id workfloneighbor csharp csharp newtonsoft error converting null system datetime value workflows neighbor csharp csharp stj could not be converted system int32 items 0 id runbooks webhoneighbor csharp csharp stj could not be converted system int32 items 0 id workflows enteneighbor csharp csharp stj could not be converted system int32 user id checklists analytneighbor csharp csharp stj could not be converted system int32 user id runbooks webhooksneighbor csharp go json cannot unmarshal array into field user email type float64 workflneighbor csharp go json cannot unmarshal number into field user email type string workflneighbor csharp go json cannot unmarshal string into field payload items type string cheneighbor csharp go json cannot unmarshal string into field payload items type string cheneighbor csharp winner csharp csharp newtonsoft error converting infinity system int32 ineighbor go go json cannot unmarshal array into field user id type string runbooks analyneighbor go go json cannot unmarshal bool into field token type string checklists data ineighbor go go json cannot unmarshal number into field user createdat type float64 workfneighbor go go json cannot unmarshal number into field user email type int workflows edgneighbor go go json cannot unmarshal object into field payload items type string runbookneighbor go go json cannot unmarshal string into field meta count type int troubleshootineighbor go go json cannot unmarshal string into field payload items type bool checklist