Registry / maps / tag2link

tag2link

JSON →
library2026.5.21jsnpmunverified

tag2link provides formatter URLs for OpenStreetMap keys, enabling conversion of OSM tags into hyperlinks. Version 2026.5.21 is current, updated periodically from Wikidata and OSM Wiki via automated scripts (Python + npm). It replaces `$1` in URL templates with the tag value. Ships TypeScript types. Key differentiator: centralized, community-maintained mapping from OSM keys to authoritative external resources (e.g., Wikidata, OSM Wiki).

npm install tag2link
INSTALL
IMPORT
SIG · TAG2LINK
T
tag2link
mapsjavascriptv2026.5.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tag2link
✓ import tag2link from 'tag2link'
✗ const tag2link = require('tag2link')
Package is ESM-only; default export is the main JSON object mapping keys to URL templates.
Tag2LinkData
✓ import type { Tag2LinkData } from 'tag2link'
TypeScript type for the exported JSON structure; no runtime value.
entries
✓ import { entries } from 'tag2link'
Named export for an array of {key, url} objects, available since v2026.5.0.

Demonstrates importing the default export, looking up a formatter URL by OSM key, and substituting the tag value.

import tag2link from 'tag2link'; // Get the formatter URL for a given OSM key const key = 'highway'; const urlTemplate = tag2link[key]; if (urlTemplate) { // Replace $1 with the tag value to get a concrete URL const tagValue = 'primary'; const fullUrl = urlTemplate.replace('$1', tagValue); console.log(fullUrl); // e.g., "https://wiki.openstreetmap.org/wiki/Key:highway" } else { console.log('No formatter URL found for key:', key); }
Debug
Known issues
gotchaThe exported object keys are OSM keys (e.g., 'highway'), not prefixed with 'key:' or 'tag:'.
fix
Access directly with the key string as it appears in OSM (e.g., 'highway', 'amenity').
affects: >=0.0.0
gotchaNot all OSM keys have formatter URLs; missing keys yield undefined.
fix
Always check for existence before accessing or use optional chaining.
affects: >=0.0.0
gotchaURL templates contain $1 placeholder; some URLs may require URL-encoding of the tag value.
fix
Use encodeURIComponent($1) in replacement if the template does not expect raw values.
affects: >=0.0.0
breakingPackage migrated to ESM-only starting v2026.5.0; CommonJS require() fails.
fix
Use dynamic import() or switch to ESM-compatible environment. For older versions, pin to <2026.5.0.
affects: >=2026.5.0
breakingIndex.json removed in favor of package exports; paths like 'tag2link/index.json' no longer work.
fix
Import directly from 'tag2link' (default export) or from 'tag2link/entries' for array format.
affects: >=2026.5.0
Errors
Common errors & fixes
Cannot find module 'tag2link/index.json'
Package restructured; index.json is no longer a direct file path.
fix
Use `import tag2link from 'tag2link'` instead.
require() of ES Module tag2link not supported
Package is ESM-only since v2026.5.0.
fix
Switch to ESM environment or use dynamic import: `const tag2link = await import('tag2link');`
TypeError: tag2link[key] is undefined
Key not present in the mapping or typo.
fix
Check the exact OSM key and that a formatter URL exists (e.g., 'highway' works, 'highwayy' does not).
Error: Cannot find module 'tag2link'
Package not installed or incorrect import path.
fix
Run `npm install tag2link` and ensure import path is exactly 'tag2link'.
Upgrade
Version history
2026.5.21latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
tag2link — npm install tag2link · libregistry