1001Ferramentas
🧩Dev

URI Template Builder (RFC 6570)

Paste a URI Template and the variable values and generate the expanded URI. Supports level 1-4 (path, query, fragment).

URI expandida

RFC 6570 URI Templates: the eight operators

A URI Template describes a family of addresses with markers in braces, and RFC 6570 defines exactly how each marker expands. It is what the GitHub API returns in its link fields, and what lets a client assemble the right URL without concatenating strings. The page expands the template with the values you supply, applying each operator's encoding rules.

The difference that matters most is between the plain marker and the plus operator. The plain one encodes reserved characters, so a slash inside the value becomes its percent-encoded form and does not separate path segments. The plus one preserves reserved characters, which suits a variable holding a whole path. Confusing the two is the source of broken URLs or, worse, path traversal when the value comes from a user.

The other six operators add punctuation automatically: dot for a label, slash for a path segment, semicolon for a path parameter, question mark to open the query, ampersand to continue it, and hash for a fragment. Each knows which separator to use between values and whether to write the variable name — and that is exactly what saves assembling the URL by hand.

Frequently asked questions

What do the modifiers do?
There are two. A colon followed by a number takes a prefix of the value, handy for building a path from the first characters of a hash. An asterisk explodes a list or map into several elements instead of joining them with commas, and the result depends on the operator — with a question mark, for instance, each item gets its own name and value pair.
What happens to a variable with no value?
The standard distinguishes undefined from empty. An undefined variable simply vanishes from the expansion, leaving no stray separator. A variable defined as an empty string does appear: under the named operators it becomes the name followed by an equals sign, and under the others it contributes an empty element.
Can you go the other way?
Not reliably, and the standard says so. Expansion loses information — there is no way to tell, from the finished URL, how many values were exploded or where a variable containing the separator ended. Anyone needing to extract values from a URL uses pattern-based routing, which is a different problem.

Related Tools