Mkjson
MIRROR. A commandline tool to generate static or random JSON records
Install / Use
/learn @mfussenegger/MkjsonREADME
Status
Development moved to codeberg
mkjson
mkjson is a CLI to generate JSON records.
Static JSON:
↪ mkjson x=10 y=20 foo=bar
{"foo":"bar","x":10,"y":20}
Generated random data:
↪ mkjson --num 3 id="uuid4()" x="randomInt(0, 10)"
{"id":"2c6ce42f-5f7d-4e65-a1a1-8b39f6cfce19","x":6}
{"id":"d4c1af69-3cdd-417d-98e0-d3774f5fa1be","x":8}
{"id":"8fc064c9-57ba-4d78-b205-57899776e757","x":6}
It takes fieldName=value or fieldName=provider() pairs as
argument. Each pair will result in a field within the JSON object.
To generate infinite records, use:
↪ mkjson --num Inf
Examples
Using fromFile and oneOf:
↪ mkjson --num 3 w="oneOf(fromFile('/usr/share/dict/words'))"
{"w":"Karl"}
{"w":"demographic"}
{"w":"calumny's"}
Use dotted notation to create objects:
↪ mkjson point.x=10 point.y=20
{"point":{"x":10,"y":20}}
Or nest calls to create objects:
↪ mkjson obj=$(mkjson xs="array(randomInt(0, 4), randomInt(5, 9))")
{"obj":{"xs":[2,5]}}
Or use the object provider with various providers. Argument are key, value [, ...] pairs:
↪ mkjson obj="object(dt, randomDateTime(), type, fromRegex('[a-z]{4}-\d+'), xs, replicate(5, randomInt(0, 10)))"
{"obj":{"dt":"2099-09-11T16:33:41Z","xs":[6,8,5,2,0],"type":"ldwa-2667786160"}}
You may also want to read this introduction and sample use case.
Available providers
- uuid1
- uuid4
- null
- randomBool
- randomChar
- randomInt(lower, upper)
- randomDouble(lower, upper)
- randomDate [(lower, upper)]
- randomDateTime [(lower, upper)]
- array(expr [, ...])
- oneOf(arrayExpr)
- oneOf(expr, expr [, ...])
- replicate(number, expr)
- object(key, value [, ...])
- fromFile(fileName)
- fromRegex(pattern)
- join(sep, val1, [, ...])
- join(array)
Installation
Get a pre-build binary from the releases page or build it yourself:
Install stack:
curl -sSL https://get.haskellstack.org/ | sh
Install mkjson:
git clone https://github.com/mfussenegger/mkjson.git
cd mkjson
stack install
Alternatives
There are some alternatives if you're not so interested in the random-value
generation aspect of mkjson:
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
