head
Preview the first N lines of files or stdin as JSON. Supports negative-N to skip all but last N lines and --raw for plain text.
Instructions
Return the first N lines (default 10) of files or stdin as JSON. Read-only, no side effects. Returns JSON with line array by default; use --raw for plain text. Supports negative-N to skip all but the last N lines. Use to preview file beginnings or extract headers. Not for viewing file endings — use 'tail' for the last N lines. See also 'tail', 'cat'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| raw | No | Write raw selected lines without a JSON envelope. | |
| path | Yes | File to read. | |
| lines | No | Number of lines. | |
| encoding | No | Text encoding (default: utf-8). Use 'auto' for BOM/autodetection. | utf-8 |
| show_encoding | No | Include encoding detection metadata in JSON result. | |
| encoding_errors | No | How to handle encoding errors (default: replace). | replace |
| encoding_profile | No | Locale-aware encoding fallback profile for auto-detection. |