I'm trying to use an endpoint in Mapbox vector tile format. I can access the .pbf's ok, but there's no documentation or TileJSON endpoint.

How can I find the names of layers that exist within the tiles? That is, the value that I would set to source-layer in a vector source in Mapbox-GL-JS.

Theoretically this must be doable, but I don't know any tool that lets me achieve this.

(In this particular case, it's a WMTS endpoint on GeoServer, but I'd be more interested in solutions that work generally.)


If you're okay to write a NodeJS script you can use

const request = require('request');
const VectorTile = require('@mapbox/vector-tile').VectorTile;
const Pbf = require('pbf');
const zlib = require('zlib');

    url: 'https://example.com/1/2/3.pbf',
    encoding: null

}, (err, response, body) => {
    try {
         body = zlib.gunzipSync(body);
    } catch (e) {

    const tile = new VectorTile(new Pbf(body));
    console.log('Vector source layers found: ', Object.keys(tile.layers).join(', '))


Try this on Runkit: https://runkit.com/stevebennett/get-layer-names-and-keys-from-vector-tile

| improve this answer | |
  • Awesome, that worked with a couple of tweaks. It seems unzipping of the body is supported automatically by Request, so removed that. – Steve Bennett Jun 27 '18 at 5:32
  • Ok, too hasty. Updated version works with both gzipped and non-gzipped sources. Maybe the gzip is at lower level. Who knows. – Steve Bennett Jun 27 '18 at 5:45
  • Maybe it depends if the HTTP response includes the right headers or not. – AndrewHarvey Jun 27 '18 at 9:36
  • 1
    I've made a runkit version of this here: runkit.com/stevebennett/… – Steve Bennett Jul 19 '18 at 1:54

Using Andrew's code above, I've now made a website to solve this problem:


Just paste the URL of any tile, and it lists the names of the layers and their attributes.

Or, as an API:

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.