เครือข่าย/HTTP
Query String ↔ JSON
แยก query string ของ URL เป็นอ็อบเจ็กต์ JSON หรือประกอบ JSON กลับเป็น query string
A URL's query string (the part after ?) is a flat set of key-value pairs, while JSON supports nested structures and data types. This tool converts between the two, including repeated keys and arrays.
How to use it
- Query → JSON: paste a query string (with or without the leading ?) to get a JSON object with decoded parameter values.
- JSON → Query: paste a JSON object to build a query string from it with correctly URL-encoded values.
- Repeated keys (a=1&a=2) are automatically recognized as an array in the JSON output.
Common uses
- Building query parameters from a JSON configuration object for an API request.
- Reading a complex query string with dozens of parameters in a structured, readable form.
- Debugging why a parameter isn't reaching the backend — checking its encoding and structure after conversion.
Things to keep in mind
Every value in a query string is text — "true", "false", or "42" stay strings in the JSON until code explicitly converts them to the right type.
Nested objects and arrays have no single standard query-string notation — different backend frameworks (PHP, Rails, Express) use slightly different syntax (a[b]=1 vs a.b=1).
บทความเกี่ยวกับเครื่องมือนี้: คิวรีสตริงกับ JSON: อะไรเหมาะกว่าสำหรับส่งข้อมูลที่ซับซ้อน
คำถามที่พบบ่อย
เครื่องมือนี้จัดการชื่อพารามิเตอร์ที่ซ้ำกันอย่าง ?tag=a&tag=b อย่างไร?
คีย์ที่ซ้ำกันมักถูกรวบรวมเป็นอาร์เรย์ (tag: ["a", "b"]) แทนที่จะเขียนทับกัน ซึ่งตรงกับวิธีที่เฟรมเวิร์กแบ็กเอนด์ส่วนใหญ่แยกวิเคราะห์ query string
เกิดอะไรขึ้นกับอักขระพิเศษระหว่างการแปลง?
อักขระที่เข้ารหัสแบบเปอร์เซ็นต์ (เช่น %20 สำหรับช่องว่าง) จะถูกถอดรหัสกลับเป็นรูปแบบตัวอักษรจริงเมื่อแปลงเป็น JSON และเข้ารหัสใหม่เมื่อแปลง JSON กลับเป็น query string
URL หรือข้อมูลของฉันถูกส่งไปที่ไหนเพื่อทำการแปลงนี้หรือไม่?
ไม่ การแปลงทั้งหมดทำงานในเบราว์เซอร์ของคุณ ไม่มีการส่งไปยังเซิร์ฟเวอร์
ความยาวสูงสุดที่ปลอดภัยของ URL คือเท่าไร?
ประมาณ 2,000 อักขระ — ขีดจำกัดร่วมที่ระมัดระวังที่สุดระหว่างเบราว์เซอร์และเซิร์ฟเวอร์ยอดนิยม สำหรับข้อมูลจำนวนมากกว่านี้ ควรใช้คำขอ POST พร้อม body แทนคิวรีสตริง
จะส่งค่า true/false หรือตัวเลขผ่านคิวรีสตริงได้อย่างไร?
คิวรีสตริงจะเก็บเป็นข้อความเสมอ — ค่าอย่าง "false" หรือ "42" ยังคงเป็นสตริงจนกว่าโค้ดฝั่งเซิร์ฟเวอร์หรือไคลเอนต์จะรู้จำอย่างชัดเจนและแปลงเป็นบูลีนหรือตัวเลข