[0m
jless - a terminal JSON viewer
[1mSUMMARY OF JLESS COMMANDS[0m
Commands marked with * may be preceded by a number, [4mN[0m, which will
repeatedly perform a command the given number of times. A key
preceded by a caret indicates the Ctrl key; thus ^E is ctrl-E.
Commands requiring multiple key-presses may be cancelled with the
Escape key.
q ^c Exit jless.
F1 :help Show this help screen.
[1mMOVING[0m
j DownArrow * Move focus down one line (or [4mN[0m lines).
^n Enter
k UpArrow * Move focus up one line (or [4mN[0m lines).
^p Backspace
h LeftArrow When focused on an expanded object or array, collapse the
object or array. Otherwise, move focus to the parent of
the focused node.
H Focus the parent of the focused node, even if it is an
expanded object or array.
l RightArrow When focused on a collapsed object or array, expand the
object or array. When focused on an expanded object or
array, move focus to the first child. When focused on
non-container values, does nothing.
J * Move to the focused node's next sibling 1 or [4mN[0m times.
K * Move to the focused node's previous sibling 1 or [4mN[0m times.
w * Move forward until the next change in depth 1 or [4mN[0m times.
b * Move backwards until the next change in depth 1 or [4mN[0m times.
PageDown ^f * Move down by one window (or [4mN[0m windows).
PageUp ^b * Move up by one window (or [4mN[0m windows).
0 ^ Move to the first sibling of the focused node's parent.
$ Move to the last sibling of the focused node's parent.
Home Focus the first line in the input.
End Focus the last line in the input.
g * Focus the first line in the input if no count is given. If a
count is given, focus that line number. If the line isn't
visible, focus the last visible line before it.
G * Focus the last line in the input if no count is given. If a
count is given, focus that line number, expanding any of its
parent nodes if necessary.
c Shallow collapse the focused node and all its siblings.
C Deeply collapse the focused node and all its siblings.
e Shallow expand the focused node and all its siblings.
E Deeply expand the focused node and all its siblings.
Space Toggle the collapsed state of the currently focused node.
[1mSCROLLING[0m
^e * Scroll down one line (or [4mN[0m lines).
^y * Scroll up one line (or [4mN[0m lines).
^d * Scroll down by half the height of the screen (or by [4mN[0m lines).
^u * Scroll up by half the height of the screen (or by [4mN[0m lines).
For this command and ^d, focus is also moved by the specified
number of lines. If no count is specified, the number of
lines to scroll by is recalled from previous executions.
zz Move the focused node to the center of the screen.
zt Move the focused node to the top of the screen.
zb Move the focused node to the bottom of the screen.
. * Scroll a truncated value one char to the right (or [4mN[0m chars).
, * Scroll a truncated value one char to the left (or [4mN[0m chars).
; Scroll a truncated value all the way to the end, or, if
already at the end, back to the start.
< Decrease the indentation of every line by one (or [4mN[0m) tabs.
> Increase the indentation of every line by one (or [4mN[0m) tabs.
[1mCOPYING AND PRINTING[0m
You can copy various parts of the JSON file to your clipboard using
any one of a set of commands starting with 'y'.
Alternatively, you can print out values using 'p'. This is useful for
viewing long string values all at once, or if the clipboard functionality
is not working; mouse-tracking will be temporarily disabled, allowing you
to use your terminal's native clipboard capabilities to select and copy
the desired text.
yy pp Copy/print the currently focused value, pretty printed. When focused
on the key/value pair of an object, this will [4mnot[0m include the key.
yv pv Copy/print the currently focused value, like yy/pp, but "nicely"
printed on one line with spaces instead of pretty printed.
ys ps When the currently focused value is a string, copy/print the contents
of the string, with all escape sequences, except control characters,
unescaped.
yk pk Copy/print the object key on the currently focused line. When in data
mode this will not include quotes around the key if the key is a
valid JavaScript identifier.
yp pP Copy/print the path from the top level JSON root to the currently
focused value. Object keys will be accessed using ".key" unless they
are not valid JavaScript identifiers.
yb pb Same as yp, but use square brackets for all object key accesses.
Useful if getting the path for use in an environment that doesn't
support the ".key" syntax, e.g. Python.
yq pq Copy/print a path that can be used by jq to filter the input JSON and
return the currently focused value.
[1mSEARCH[0m
jless supports full-text search over the input JSON.
/pattern * Search forward for the given pattern (or its [4mN[0mth occurrence).
?pattern * Search backwards for the given pattern (or its [4mN[0mth occurrence).
* * Move to the next occurrence of the object key on the focused
line (or move forward [4mN[0m occurrences)
# * Move to the previous occurrence of the object key on the
focused line (or move backwards [4mN[0m occurrences)
n * Move in the search direction to the next match (or forward
[4mN[0m matches).
N * Move in the opposite of the search direction to the previous
match (or previous [4mN[0m matches).
Searching uses "smart case" by default. If the input pattern doesn't
contain any capital letters, a case insensitive search will be
performed. If there are any capital letters, it will be case sensitive.
You can force a case-sensitive search by appending '/s' to your query.
A trailing slash will be removed from a pattern; to search for a
pattern ending in '/' (or '/s'), just add another '/' to the end.
Search patterns are interpreted as mostly standard regular expressions,
with one exception. Because JSON data contains many square and curly
brackets ("[]{}"), these characters do *not* take on their usual
meanings (specifying characters classes and repetition counts
respectively) and are instead interpreted literally.
To use character classes or repetition counts, escape these characters
with a backslash.
Some examples:
/[1, 2, 3] matches an array: [1, 2, 3]
/\[bch\]at matches "bat", "cat" or "hat"
/{} matches an empty object
/(ha)\{2,3\} matches "haha" or "hahaha"
For exhaustive documentation of the supported regular expression syntax,
see the following documentation of the underlying regex engine:
https://docs.rs/regex/latest/regex/index.html#syntax
[1mSEARCH INPUT[0m
The search is *not* performed over the original input, but over a
single-line "nicely" formatted version of the input JSON. Consider the
following two ways to format an equivalent JSON blob:
{"a":1,"b":true,"c":[null,{},[],"hello"]}
{
"a": 1,
"b": true,
"c": [
null,
{},
[],
"hello"
]
}
jless will create an internal representation formatted as follows:
{ "a": 1, "b": true, "c": [null, {}, [], "hello"] }
(No spaces inside empty objects or arrays, one space inside objects
with values, no spaces inside array square brackets, no space between
an object key and ':', one space after the ':', and one space after
commas separating object entries and array elements.)
Searching will be performed over this internal representation so that
patterns can include multiple elements without worrying about
newlines or the exact input format.
When the input is newline-delimited JSON, an actual newline will
separate each top-level JSON element in the internal representation.
[1mDATA MODE VS LINE MODE[0m
jless starts in "data" mode, which displays the JSON data in a more
streamlined fashion: no closing delimiters for objects or arrays,
no trailing commas, no quotes around object keys that are valid
identifiers in JavaScript. It also shows single-line previews of
objects and arrays, and array indexes before array elements. Note
that when using full-text search, object keys will still be
surrounded by quotes.
By pressing 'm', you can switch jless to "line" mode, which displays
the input as pretty-printed JSON.
In line mode you can press '%' when focused on an open or close
delimiter of an object or array to jump to its matching pair.
[1mLINE NUMBERS[0m
jless supports displaying line numbers, and does so by default. The line
numbers do not reflect the position of a node in the original input, but
rather what line the node would appear on if the original input were
pretty printed.
jless also supports relative line numbers. When this is enabled, the
number displayed next to each line will indicate how many lines away it
is from the currently focused line. This makes it easier to use the j
and k commands with specified counts.
The appearance of line numbers can be configured via command line flags:
-n, --line-numbers Show absolute line numbers.
-N, --no-line-numbers Don't show absolute line numbers.
-r, --relative-line-numbers Show relative line numbers.
-R, --no-relative-line-numbers Don't show relative line numbers.
As well as at runtime:
:set number Show absolute line numbers.
:set nonumber Don't show absolute line numbers.
:set number! Toggle whether showing absolute line numbers.
:set relativenumber Show relative line numbers.
:set norelativenumber Don't show relative line numbers.
:set relativenumber! Toggle whether showing relative line numbers.
When just using relative line numbers, "0" will be displayed next to the
currently focused line. When both flags are set, the absolute line
number will be displayed next to the focused lines, and all other line
numbers will be relative. This matches vim's behavior.