Skip to content

feat(export): add Insomnia v5 JSON export option#10071

Open
hexbinoct wants to merge 10 commits into
Kong:developfrom
hexbinoct:feat/v5-json-export
Open

feat(export): add Insomnia v5 JSON export option#10071
hexbinoct wants to merge 10 commits into
Kong:developfrom
hexbinoct:feat/v5-json-export

Conversation

@hexbinoct

Copy link
Copy Markdown

Summary

Closes #8672.

Since the v4 → v5 format change, collections/workspaces can only be exported
as YAML. A lot of people export specifically to hand the file to other tooling
(Postman compatibility comes up repeatedly in the issue) or to diff/process it
with JSON tools, and JSON export disappeared in that transition.

I understand from #8672 that YAML was chosen deliberately to keep the sync
format diff-friendly, so this change is purely additive: it adds an
"Insomnia v5 (JSON)" option next to the existing YAML and HAR options.
YAML stays the default and the sync format is untouched.

What changed

  • getInsomniaV5DataExport now accepts an optional format: 'yaml' | 'json'
    (default 'yaml'). All five workspace scopes build the same validated
    InsomniaFile and serialize through a single serialize() helper, so the
    YAML and JSON outputs are guaranteed to be the same data.
  • The export-type modal lists "Insomnia v5 (JSON)". The collection export and
    the project/folder export paths thread the chosen format through and write
    the matching .json / .yaml extension.
  • Import detection now recognizes JSON-serialized v5 files (a { object
    carrying the *.insomnia(.rest)?/5.0 type discriminator) as well as YAML,
    so a JSON export can be re-imported. tryImportV5Data already validates with
    zod and returns errors instead of throwing, so no extra error handling was
    needed.

Testing

  • npm run type-check -w packages/insomnia
  • eslint on the changed files ✅
  • vitest for insomnia-v5.test.ts and import.test.ts ✅ (57 passing)

New tests assert that the JSON export is valid JSON, contains the same data as
the YAML export, and is detected as insomnia-5 when scanned for import.

Notes

  • No change to the default export format or the sync/git format.
  • HAR export is unaffected.

Insomnia v5 (app v11) can only export collections/workspaces as YAML.
Many people export specifically to share with other tooling (e.g. Postman)
or to diff/process the result with JSON tools, and lost JSON export in the
v4 -> v5 transition (Kong#8672).

This adds a non-destructive "Insomnia v5 (JSON)" choice alongside the
existing YAML and HAR options. YAML stays the default, so the v5
diff-friendly sync format is unchanged.

- getInsomniaV5DataExport takes an optional `format: 'yaml' | 'json'`
  (default 'yaml') and serializes the same validated InsomniaFile through a
  single serialize() helper, so YAML and JSON outputs are the same data.
- The export-type modal offers JSON; the collection and project/folder
  export paths thread the format through and pick the .json/.yaml extension.
- Import detection recognizes JSON-serialized v5 files (a `{` object with
  the `*.insomnia(.rest)?/5.0` type discriminator) in addition to YAML, so a
  JSON export round-trips back in. tryImportV5Data already validates with
  zod and never throws.
- Tests: JSON export is valid JSON, equals the YAML export's data, and is
  detected as `insomnia-5` on re-import.
@CLAassistant

CLAassistant commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not able to export Collection as JSON

2 participants