Scripting with JSON
Kimun's JSON output format makes it easy to automate note management and build custom workflows. This guide covers the JSON structure and provides practical recipes for common tasks.
Enabling JSON output
Use the --format json flag with commands that produce output:
kimun search "query" --format json
kimun notes --format jsonJSON structure
The output is a single JSON object with two top-level keys:
metadata object
workspace— active workspace nameworkspace_path— absolute path to workspace directorytotal_results— number of notes returnedquery— the search query (null fornoteslistings)is_listing— true fornotes, false forsearchgenerated_at— ISO 8601 timestamp
notes array
Each note object contains:
path— note path relative to workspace root (includes.md)title— note title (extracted from first heading or filename)content— full note contentsize— file size in bytesmodified— last modified timestamp (Unix seconds)created— creation timestamp (Unix seconds, currently same as modified)hash— content hash (hex string)journal_date— date stringYYYY-MM-DDif the note is a journal entry, otherwise absentmetadata.tags— array of#tagstrings extracted from contentmetadata.links— array of wikilink targets extracted from contentmetadata.headers— array of{level, text}objects for each Markdown heading
Common recipes
Find notes with a specific tag
kimun search "rust" --format json | jq '.notes[] | select(.metadata.tags[] == "rust")'Get note titles and paths
kimun notes --format json | jq '.notes[] | {title, path}'Count notes in workspace
kimun notes --format json | jq '.metadata.total_results'Sort notes by last modified (newest first)
kimun notes --format json | jq '[.notes[] | {title, path, modified}] | sort_by(.modified) | reverse'List all unique tags across all notes
kimun notes --format json | jq '[.notes[].metadata.tags[]] | unique | sort'Extract all wikilinks
kimun notes --format json | jq '[.notes[].metadata.links[]] | unique | sort'Find all journal entries
kimun notes --format json | jq '.notes[] | select(.journal_date != null) | {journal_date, title, path}'Find notes larger than 10KB
kimun notes --format json | jq '.notes[] | select(.size > 10240) | {path, size}'Get all headings from a search result
kimun search "project" --format json | jq '.notes[] | {path, headers: .metadata.headers}'Practical workflows
Save to file
Export all notes for backup or processing:
kimun notes --format json > notes-backup.jsonCount journal entries
Get statistics on your journaling habits:
kimun notes --format json | jq '[.notes[] | select(.journal_date != null) | .journal_date] | length'Build custom reports
Process JSON output with other tools for advanced analysis:
# Get average note size
kimun notes --format json | jq '[.notes[].size] | add / length'
# Find notes created today
kimun notes --format json | jq '.notes[] | select(.created > (now | floor - 86400))'Tips
- Use
jqfor powerful JSON filtering and transformation - Pipe JSON output to files for version control or backup
- Combine with other command-line tools for complex workflows
- Test queries with small result sets before applying to large workspaces