Ir al contenido principal
kitlocal.dev

Chuleta de jq

Ejecución local

Procesado al 100 % en tu navegador. Las entradas y salidas nunca salen de tu dispositivo.

Filtros del procesador JSON jq, pipes, construcción de objetos, arrays, select, map, group_by, reduce y flags de CLI verificados con jq 1.8.

Cómo funciona

Every jq filter transforms an input JSON stream into zero or more output JSON values. Dot (`.`) is the identity filter; pipes (`|`) pass each output of the left filter into the right filter, and `.[]` explodes an array or object into a stream of items so you can filter, map and re-wrap them with `[...]`.

Kit de supervivencia

Los comandos clave que conviene aprender primero.

40 comandos

Atajos de teclado/Enfocar búsquedaJKMover selecciónCCopiar seleccionadoFMarcar seleccionadoEscBorrar búsqueda

Inspect & format JSON

Start with `.` to validate and pretty-print JSON, or `-r`/`-c` to adapt formatting for downstream tools.

Documentación oficial: Invoking jq
  • Esencial

    Validate and pretty-print JSON with syntax highlighting.

    jq . <file.json>

    Cuándo usarlo

    Quickly format minified API responses or confirm JSON syntax from the terminal.

    Desglose

    .
    identity filter: passes the whole JSON value unchanged

    Ejemplo

    echo '{"b":2,"a":1}' | jq -c .

    Resultado

    {"b":2,"a":1}

    También funciona

    • jq -S . <file.json> (sort object keys alphabetically)

    Véase también

Access fields & arrays

Chain property names with `.a.b`, index arrays with `.[0]`, and append `?` to skip missing/null errors.

Documentación oficial: Basic filters

Filter & transform

Combine `select(cond)` to drop items and `map(...)` or `[...]` to transform the remaining ones.

Documentación oficial: Builtin operators & functions

Sort, group & aggregate

Group records by a key, deduplicate, compute totals, or flatten nested arrays.

Documentación oficial: Sorting and grouping

CLI variables, CSV & shell interop

Pass shell parameters safely with `--arg` / `--argjson` and export tables directly with `@csv` or `@tsv`.

Documentación oficial: Format strings and escaping

Pruébalo en una herramienta de KitLocal

Glosario
Filter
An expression in jq that takes a JSON value and outputs zero or more values.
Stream
Multiple values produced by `.[]` or `,` before wrapping back into an array with `[...]`.
Raw output (-r)
Outputs strings without JSON surrounding quotes — essential when feeding bash or grep.
Compact (-c)
Prints each JSON object on a single line (NDJSON / JSON Lines).

Comprobado el 15 nov 2026 · Comprobado con jq 1.8

Fuentes: jq Manual (jqlang.org)

Sustituye todo lo que esté entre corchetes angulares por tus propios valores. Los comandos proceden de la documentación oficial y los ejemplos se ejecutaron en la versión indicada.