Member-only story
Inline: a series about owning your business logic
JavaScript Query String Parsing
Or “how to overcomplicate for fun and profit”
This is part of the Inline series, a series of copy-paste code solutions to reduce our dependency on third-party packages. Please do review the About page before reading or commenting.
Skill level: intermediate
If you do not have a Medium subscription, please do read the free version here.
The problem space
Getting data from a query string is, at its most basic level, a string parsing exercise. In that sense, it’s an easy problem: string parsing has long been a solved problem. From basic token splitting to advanced regex compilation, most languages have a pretty hefty tool belt for string parsing and JavaScript is no exception.
Since this is marked as an intermediate-level article I will assume that my readers are already familiar with query strings. If not, here is a quick query-strings 101:
- The query string is the bit of the URL after the question mark. In
https://example.com?foo=bar, most people would say that the query string isfoo=bar(although some argue that the question mark should be included).









