Integrate
Open your JSON in Tool Kumar with one click
Add a button or a link to docs, READMEs, bug reports or your own app. Readers land in the viewer with the document formatted, validated and open in the view you chose. No sign-up, no API key.
Via link
Small to large JSON, up to a few MB
A link with the JSON inside it, for READMEs, docs, issues and web pages. Nothing to install. Roughly 1 to 10 MB of JSON fits, depending on how well it compresses.
How links workVia handoff
JSON of any size
A short function for your web app: one click opens Tool Kumar in a new tab and passes the JSON to it inside the browser. No link to outgrow.
How handoff worksMake your button
Paste a document, or the URL of one. Everything is built in this page; nothing you paste is sent anywhere.
For READMEs, docs and issues on GitHub or GitLab.
Logo for your own buttons
Prefer your own button style? Use the Tool Kumar logo in it, linked to Tool Kumar.
SVG scales to any size; PNG and WebP are 512 × 512 with a transparent background around the rounded tile.
1. Via link
Every link points to the home page. The documents and options follow the # as name=value pairs joined by &:
https://tools.vikasmaur.com/#a=<document>&view=tree
https://tools.vikasmaur.com/#a=<original>&b=<modified>
https://tools.vikasmaur.com/#a=<document>&b=<schema>&view=schema| Name | Value |
|---|---|
a | The document: its text compressed with raw DEFLATE and encoded as base64url without padding, or a percent-encoded http(s) URL to fetch it from. |
b | Optional. A second document in the same form. Two documents open in Compare. With view=schema, it is instead the JSON Schema the document is validated against. |
view | Optional. format, tree, table, graph, convert, compare or schema. Without it, readers keep the view they last used. |
to | Optional, with view=convert: typescript, zod, json-schema, csharp, dart, java, python, go, kotlin, swift, php, rust, protobuf, csv, xlsx, yaml, xml, toml, jsonl, flatten, unflatten. |
sep | Optional, with to=flatten or to=unflatten: what joins the keys of a path, 1 to 8 characters with no digits, backslashes or brackets, percent-encoded. The default is a dot. |
arrays | Optional, with the same targets: array indexes as bracket (a[0], the default), dot (a.0) or keep (arrays stay whole). |
depth | Optional, with to=flatten: 1, 2 or 3 levels joined into keys. The default is all of them. |
escape | Optional, with the same targets: 0 keeps keys as written, without the backslashes that otherwise mark a dot or bracket inside a key. A link to flatten or unflatten opens with exactly these options, the defaults for those it leaves out, and readers keep their own for their next visit. |
draft | Optional, with a schema: the draft for a schema without $schema. 2020-12 (the default), 2019-09, draft-07, draft-06 or draft-04. |
formats | Optional, with a schema: 1 checks format (email, date-time, uri…), which is otherwise an annotation. |
in | Optional. The format of a when it isn't JSON: yaml, csv, xml or toml. The document opens as itself, in its own format in the input, and the views show its JSON. Without it, a document is read as JSON, or by its file name when it comes from a URL (.yaml, .csv, .tsv, .xml, .toml). |
delimiter | Optional, with in=csv: what separates the fields, comma, semicolon, tab or pipe. Without it, the separator is detected, or taken from a first line such as sep=; (as Excel writes it). |
header | Optional, with in=csv: 0 when the first row is data, not column names: every row becomes an array. By default the first row names the columns and each row after it becomes an object. |
types | Optional, with in=csv: 0 keeps every value a string. By default unquoted numbers, true and false become JSON numbers and booleans, and empty fields null. A CSV link opens with exactly these options, the defaults for those it leaves out, for that visit only: readers keep their own CSV settings for their next one. |
How big a link can be
Tool Kumar sets no limit on links; browsers do. We measured the longest link each one opens when it is clicked. Because the JSON is compressed, a link holds several times its own length in JSON:
| Browser | Longest link it opens | JSON that fits, roughly |
|---|---|---|
| Firefox | about 1 MB | 1 MB of JSON full of base64 data, 3 to 4 MB of typical API data, up to 9 MB of repetitive logs |
| Chrome, Edge | about 2 MB | about twice as much: 2 to 18 MB |
| Safari | about 2 MB (measured on WebKit) | like Chrome |
A longer link doesn't open at all: the browser shows a blank page or ignores the click. The builder above shows each link's length. Valid JSON opens formatted, so compact JSON makes the shortest links.
Pasting a link into the address bar has a lower limit: Chrome and Edge keep only the first 500 KB (512,000 characters) of what is pasted there and drop the rest, so a longer link arrives cut and can't open. Clicked, the same link opens. Firefox takes a pasted link whole. To try a long link, use the builder's Open link button.
Sharing in chats and email
Chat apps allow far less per message than browsers: about 2,000 characters on Discord and 40,000 on Slack. Two ways to share bigger JSON:
- Link to where the JSON is hosted. Put it in a GitHub Gist or any file a browser can fetch, then link to its address:
'https://tools.vikasmaur.com/#a=' + encodeURIComponent(url). The link stays short whatever the size, and Tool Kumar fetches the file when it opens. - Use the handoff from your web app (below): a button in your app opens Tool Kumar with the JSON, with no link at all.
Make links in your code
Copy this function into your project. It runs in browsers and in Node.js 18 or later, with no dependencies:
// A link that opens `json` in Tool Kumar: a JSON string (kept as
// written) or any value. Options: compare (a second document, opens
// Compare), schema (a JSON Schema: opens the Schema view, validating
// json against it), view ('tree', 'table', 'graph'…), to (Convert
// target), and with to 'flatten' or 'unflatten': sep (default '.'),
// arrays ('dot' or 'keep'; default a[0]), depth (1 to 3; default all),
// escape (false). in ('yaml', 'csv', 'xml' or 'toml': json is text in
// that format), and with in 'csv': delimiter ('comma', 'semicolon',
// 'tab' or 'pipe'; default detected), header (false: no header row),
// types (false: every value a string).
async function toolKumarLink(json, options = {}) {
const { compare, schema, view, to, sep, arrays, depth, escape } = options;
const { in: format, delimiter, header, types } = options;
const encode = async (value) => {
const text = typeof value === 'string' ? value : JSON.stringify(value);
const stream = new Blob([text]).stream()
.pipeThrough(new CompressionStream('deflate-raw'));
const bytes = new Uint8Array(await new Response(stream).arrayBuffer());
let binary = '';
for (let i = 0; i < bytes.length; i += 0x8000) {
binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
}
return btoa(binary)
.replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
};
let hash = 'a=' + (await encode(json));
if (schema !== undefined) hash += '&b=' + (await encode(schema)) + '&view=schema';
else if (compare !== undefined) hash += '&b=' + (await encode(compare));
if (view && schema === undefined) hash += '&view=' + view;
if (to) hash += '&to=' + to;
// (A separator with half an emoji can't be encoded: it is left out.)
try {
if (sep) hash += '&sep=' + encodeURIComponent(sep);
} catch {}
if (arrays) hash += '&arrays=' + arrays;
if (depth) hash += '&depth=' + depth;
if (escape === false) hash += '&escape=0';
if (format) hash += '&in=' + format;
if (delimiter) hash += '&delimiter=' + delimiter;
if (header === false) hash += '&header=0';
if (types === false) hash += '&types=0';
return 'https://tools.vikasmaur.com/#' + hash;
}interface ToolKumarOptions {
/** A second document: the link opens Compare. */
compare?: unknown;
/** A JSON Schema: the link opens the Schema view, validating the document against it. */
schema?: unknown;
view?: 'format' | 'tree' | 'table' | 'graph' | 'convert' | 'compare' | 'schema';
/** Convert target, with view: 'convert'. */
to?:
| 'typescript' | 'zod' | 'json-schema' | 'csharp' | 'dart'
| 'java' | 'python' | 'go' | 'kotlin' | 'swift'
| 'php' | 'rust' | 'protobuf' | 'csv' | 'xlsx'
| 'yaml' | 'xml' | 'toml' | 'jsonl' | 'flatten'
| 'unflatten';
/** With to: 'flatten' or 'unflatten': what joins the keys (default '.'). */
sep?: string;
/** Array indexes as a.0 ('dot') or none ('keep'); default a[0]. */
arrays?: 'bracket' | 'dot' | 'keep';
/** Levels joined into keys (default: all). */
depth?: 1 | 2 | 3;
/** false: keys stay as written (default: escaped with backslashes). */
escape?: boolean;
/** The document's format when it isn't JSON: json is text in that format. */
in?: 'yaml' | 'csv' | 'xml' | 'toml';
/** With in: 'csv': what separates the fields (default: detected). */
delimiter?: 'comma' | 'semicolon' | 'tab' | 'pipe';
/** With in: 'csv': false when the first row is data, not column names. */
header?: boolean;
/** With in: 'csv': false keeps every value a string. */
types?: boolean;
}
// A link that opens `json` in Tool Kumar: a JSON string (kept as
// written) or any value.
async function toolKumarLink(
json: unknown,
options: ToolKumarOptions = {},
): Promise<string> {
const { compare, schema, view, to, sep, arrays, depth, escape } = options;
const { in: format, delimiter, header, types } = options;
const encode = async (value: unknown): Promise<string> => {
const text = typeof value === 'string' ? value : JSON.stringify(value);
const stream = new Blob([text]).stream()
.pipeThrough(new CompressionStream('deflate-raw'));
const bytes = new Uint8Array(await new Response(stream).arrayBuffer());
let binary = '';
for (let i = 0; i < bytes.length; i += 0x8000) {
binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
}
return btoa(binary)
.replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
};
let hash = 'a=' + (await encode(json));
if (schema !== undefined) hash += '&b=' + (await encode(schema)) + '&view=schema';
else if (compare !== undefined) hash += '&b=' + (await encode(compare));
if (view && schema === undefined) hash += '&view=' + view;
if (to) hash += '&to=' + to;
// (A separator with half an emoji can't be encoded: it is left out.)
try {
if (sep) hash += '&sep=' + encodeURIComponent(sep);
} catch {}
if (arrays) hash += '&arrays=' + arrays;
if (depth) hash += '&depth=' + depth;
if (escape === false) hash += '&escape=0';
if (format) hash += '&in=' + format;
if (delimiter) hash += '&delimiter=' + delimiter;
if (header === false) hash += '&header=0';
if (types === false) hash += '&types=0';
return 'https://tools.vikasmaur.com/#' + hash;
}const link = await toolKumarLink(response, { view: 'tree' });
const diff = await toolKumarLink(before, { compare: after });
const checked = await toolKumarLink(response, { schema: userSchema });
const sheet = await toolKumarLink(csvText, { in: 'csv', delimiter: 'semicolon' });A link to a URL needs no compression: 'https://tools.vikasmaur.com/#a=' + encodeURIComponent(url). The reader's browser fetches it, so its server must allow cross-origin requests (CORS); public GitHub files and most public APIs do. In other languages:
// Node.js, synchronous
import { deflateRawSync } from 'node:zlib';
const link = 'https://tools.vikasmaur.com/#a=' + deflateRawSync(JSON.stringify(data)).toString('base64url');# Python
import base64, json, zlib
z = zlib.compressobj(9, zlib.DEFLATED, -15) # -15: raw DEFLATE
raw = z.compress(json.dumps(data, separators=(",", ":")).encode()) + z.flush()
link = "https://tools.vikasmaur.com/#a=" + base64.urlsafe_b64encode(raw).decode().rstrip("=")2. Via handoff, for bigger JSON
When the JSON is too big for a link, open Tool Kumar from your web app and pass the JSON to it directly. Copy this function into your code:
// Opens `json` in a new Tool Kumar tab, any size. Call it straight
// from a click. Options: compare, schema, view, to, sep, arrays, depth,
// escape, in, delimiter, header, types (as for links). Resolves with the
// tab once Tool Kumar has the document.
function openInToolKumar(json, options = {}) {
const { compare, schema, view, to, sep, arrays, depth, escape } = options;
const { in: format, delimiter, header, types } = options;
const origin = 'https://tools.vikasmaur.com';
const text = (value) => typeof value === 'string' || value === undefined
? value : JSON.stringify(value);
const tab = window.open(origin + '/#handoff', '_blank');
if (!tab) return Promise.reject(new Error('The browser blocked the tab'));
return new Promise((resolve, reject) => {
const fail = (why) => done(new Error('Tool Kumar: ' + why));
const timer = setTimeout(() => fail('no answer'), 60000);
function done(error) {
clearTimeout(timer);
removeEventListener('message', onMessage);
if (error) reject(error);
else resolve(tab);
}
function onMessage(e) {
if (e.source !== tab || e.origin !== origin) return;
const kind = e.data && e.data.toolkumar;
if (kind === 'ready') {
const a = text(json);
const b = text(schema === undefined ? compare : schema);
const v = schema === undefined ? view : 'schema';
tab.postMessage({
toolkumar: 'open', a, b, view: v, to, sep, arrays, depth, escape,
in: format, delimiter, header, types,
}, origin);
} else if (kind === 'opened') done();
else if (kind === 'error') fail(e.data.reason);
}
addEventListener('message', onMessage);
});
}interface ToolKumarOptions {
/** A second document: the link opens Compare. */
compare?: unknown;
/** A JSON Schema: the link opens the Schema view, validating the document against it. */
schema?: unknown;
view?: 'format' | 'tree' | 'table' | 'graph' | 'convert' | 'compare' | 'schema';
/** Convert target, with view: 'convert'. */
to?:
| 'typescript' | 'zod' | 'json-schema' | 'csharp' | 'dart'
| 'java' | 'python' | 'go' | 'kotlin' | 'swift'
| 'php' | 'rust' | 'protobuf' | 'csv' | 'xlsx'
| 'yaml' | 'xml' | 'toml' | 'jsonl' | 'flatten'
| 'unflatten';
/** With to: 'flatten' or 'unflatten': what joins the keys (default '.'). */
sep?: string;
/** Array indexes as a.0 ('dot') or none ('keep'); default a[0]. */
arrays?: 'bracket' | 'dot' | 'keep';
/** Levels joined into keys (default: all). */
depth?: 1 | 2 | 3;
/** false: keys stay as written (default: escaped with backslashes). */
escape?: boolean;
/** The document's format when it isn't JSON: json is text in that format. */
in?: 'yaml' | 'csv' | 'xml' | 'toml';
/** With in: 'csv': what separates the fields (default: detected). */
delimiter?: 'comma' | 'semicolon' | 'tab' | 'pipe';
/** With in: 'csv': false when the first row is data, not column names. */
header?: boolean;
/** With in: 'csv': false keeps every value a string. */
types?: boolean;
}
// Opens `json` in a new Tool Kumar tab, any size. Call it straight
// from a click. Resolves with the tab once Tool Kumar has the document.
function openInToolKumar(
json: unknown,
options: ToolKumarOptions = {},
): Promise<Window> {
const { compare, schema, view, to, sep, arrays, depth, escape } = options;
const { in: format, delimiter, header, types } = options;
const origin = 'https://tools.vikasmaur.com';
const text = (value: unknown): string | undefined =>
typeof value === 'string' || value === undefined
? value
: JSON.stringify(value);
const tab = window.open(origin + '/#handoff', '_blank');
if (!tab) return Promise.reject(new Error('The browser blocked the tab'));
return new Promise<Window>((resolve, reject) => {
const onMessage = (e: MessageEvent) => {
if (e.source !== tab || e.origin !== origin) return;
const data = e.data as { toolkumar?: string; reason?: string } | null;
if (data?.toolkumar === 'ready') {
const a = text(json);
const b = text(schema === undefined ? compare : schema);
const v = schema === undefined ? view : 'schema';
tab.postMessage({
toolkumar: 'open', a, b, view: v, to, sep, arrays, depth, escape,
in: format, delimiter, header, types,
}, origin);
} else if (data?.toolkumar === 'opened') done();
else if (data?.toolkumar === 'error') fail(data.reason ?? 'error');
};
const done = (error?: Error) => {
clearTimeout(timer);
removeEventListener('message', onMessage);
if (error) reject(error);
else resolve(tab);
};
const fail = (why: string) => done(new Error('Tool Kumar: ' + why));
const timer = setTimeout(() => fail('no answer'), 60000);
addEventListener('message', onMessage);
});
}Call it straight from a click, without awaiting anything first, or the browser blocks the new tab:
button.addEventListener('click', () => {
openInToolKumar(hugeResponseText, { view: 'table' })
.catch((error) => console.warn(error.message)); // a blocked tab, for example
});How it works
- Your page opens
https://tools.vikasmaur.com/#handoffin a new tab. - When Tool Kumar is ready, it tells your page with
{ toolkumar: "ready", version: 1 }. - Your page sends
{ toolkumar: "open", a, b, view, to }to that tab, whereaandbare the JSON text. Withto: "flatten"or"unflatten"it may addsep,arrays,depth(a number) andescape(a boolean), as for links. Withview: "schema",bis the JSON Schema. Within("yaml","csv","xml"or"toml"),ais text in that format; within: "csv"it may adddelimiter("comma","semicolon","tab"or"pipe"), andheaderandtypes(booleans:falseforheader=0andtypes=0), also for that visit only. - Tool Kumar opens it and answers
{ toolkumar: "opened" }, or{ toolkumar: "error", reason }.
The JSON goes from one tab to the other inside the browser, with no link involved, so it can be as big as a browser tab handles: a few hundred MB, the same as opening a file. The tab listens only to the page that opened it, accepts one request and stops listening after two minutes. If your page sends Cross-Origin-Opener-Policy: same-origin, use same-origin-allow-popups so the two tabs can talk.
Privacy and security
- Documents stay in the link's fragment, which browsers don't send to servers. Tool Kumar removes it from the address bar once the document is open.
- A handed-over document goes from one browser tab to the other and never touches a server.
- A linked document replaces what the reader had open, and one undo brings that back. Links can't run code: documents are only shown as text.
- Anyone with a link can read the document in it, so share links to sensitive data only with people who may see it.
- Our analytics record only that a document arrived by link or handover, never the link or its document. See the privacy page.
Inside the viewer, Share makes these links too: it copies a link to the open document in its current view, or to both documents while you compare them. Open the viewer.