KKitForma.

Language

EnglishEnglishTürkçeTurkishDeutschGermanGuide unavailable in this language · open toolsEspañolSpanishGuide unavailable in this language · open toolsFrançaisFrenchGuide unavailable in this language · open toolsPortuguêsPortugueseGuide unavailable in this language · open toolsItalianoItalianGuide unavailable in this language · open toolsNederlandsDutchGuide unavailable in this language · open toolsPolskiPolishGuide unavailable in this language · open toolsРусскийRussianGuide unavailable in this language · open toolsУкраїнськаUkrainianGuide unavailable in this language · open toolsSvenskaSwedishGuide unavailable in this language · open toolsNorskNorwegianGuide unavailable in this language · open toolsDanskDanishGuide unavailable in this language · open toolsSuomiFinnishGuide unavailable in this language · open toolsČeštinaCzechGuide unavailable in this language · open toolsRomânăRomanianGuide unavailable in this language · open toolsΕλληνικάGreekGuide unavailable in this language · open toolsالعربيةArabicGuide unavailable in this language · open toolsעבריתHebrewGuide unavailable in this language · open toolsفارسیPersianGuide unavailable in this language · open toolsاردوUrduGuide unavailable in this language · open toolsहिन्दीHindiGuide unavailable in this language · open toolsবাংলাBengaliGuide unavailable in this language · open toolsதமிழ்TamilGuide unavailable in this language · open toolsతెలుగుTeluguGuide unavailable in this language · open toolsमराठीMarathiGuide unavailable in this language · open toolsગુજરાતીGujaratiGuide unavailable in this language · open tools简体中文Chinese SimplifiedGuide unavailable in this language · open tools繁體中文Chinese TraditionalGuide unavailable in this language · open tools日本語JapaneseGuide unavailable in this language · open tools한국어KoreanGuide unavailable in this language · open toolsTiếng ViệtVietnameseGuide unavailable in this language · open toolsไทยThaiGuide unavailable in this language · open toolsBahasa IndonesiaIndonesianGuide unavailable in this language · open toolsBahasa MelayuMalayGuide unavailable in this language · open toolsFilipinoFilipinoGuide unavailable in this language · open toolsKiswahiliSwahiliGuide unavailable in this language · open toolsAfrikaansAfrikaansGuide unavailable in this language · open toolsMagyarHungarianGuide unavailable in this language · open toolsБългарскиBulgarianGuide unavailable in this language · open toolsHrvatskiCroatianGuide unavailable in this language · open toolsSrpskiSerbianGuide unavailable in this language · open toolsSlovenčinaSlovakGuide unavailable in this language · open toolsSlovenščinaSlovenianGuide unavailable in this language · open toolsLietuviųLithuanianGuide unavailable in this language · open toolsLatviešuLatvianGuide unavailable in this language · open toolsEestiEstonianGuide unavailable in this language · open toolsCatalàCatalanGuide unavailable in this language · open toolsEuskaraBasqueGuide unavailable in this language · open tools
← Questions & answers

KITFORMA · EDITORIAL ANSWER

Why does a Base64 query token lose its plus signs?

KitForma editorial guide. Preserve plus, slash and equals characters by passing a raw Base64 value to URLSearchParams rather than interpolating query text.

JavaScript & TypeScript →

Step-by-step answer

Form-style query parsing turns a raw plus sign into a space. Pass the unencoded value to URLSearchParams.set so its serializer can escape the value exactly once. Runnable example:
javascript
const token = "+/8=";
const params = new URLSearchParams();
params.set("token", token);
const query = params.toString();
console.log(query);
console.log(new URLSearchParams(query).get("token") === token);
console.log(JSON.stringify(new URLSearchParams("token=" + token).get("token")));
Expected result:
text
token=%2B%2F8%3D
true
" /8="
Why it works: The third line demonstrates the broken interpolation path. A raw plus has form-encoding meaning; %2B represents a literal plus. Pre-encoding token before set would encode the percent sign again, changing the decoded value. Scope and checks: Run in Node.js 24 or a modern browser console. This is query-component handling, not whole-URL encoding or encryption. Base64URL is another alphabet only when both ends agree to it. Avoid putting real credentials in diagnostic URLs because URLs can be recorded in history and logs. Related tools and guides: Inspect decoded query values: https://kitforma.com/en/query-string-parser/ Base64URL conversion guide: https://kitforma.com/en/community/questions/7aa10000-0000-4000-8000-000000001220/ Primary sources (reviewed 2026-10-08): WHATWG URL — URLSearchParams and form-urlencoded parsing: https://url.spec.whatwg.org/#interface-urlsearchparams

Sources and verification

Sources checked:

This editorial answer was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.

Discussion and community answers

Loading community…
KitForma

What would you like to do?