Sitemap
Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Member-only story

Inline: a series about owning your business logic

JavaScript Query String Parsing

Or “how to overcomplicate for fun and profit”

13 min readOct 6, 2024

--

Press enter or click to view image in full size
Photo by Crystal Kwok on Unsplash

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 is foo=bar (although some argue that the question mark should be included).

--

--

Charles Sullivan
Charles Sullivan

Written by Charles Sullivan

Software developer, opera singer, cook, scientist, humanist...I spend half my time seeking evidence and the other half delighting in the mess that is humanity.