Docs / Editing tools
Search and replace
Last updated:
Search and replace finds text in the open document and changes it. It works in the Tree, Table, and Raw views, with plain text or a regular expression. Search and replace is free in Prettify.
Open the search bar
Load a document first. Search is available once data is present.
- Press
Cmd+F(Mac) /Ctrl+F(Windows, Linux) to open search. - Press
Cmd+H(Mac) /Ctrl+H(Windows, Linux) to open search with the replace row expanded. On the Mac desktop app,Cmd+Hhides the app, so pressCmd+Option+Fthere. - Click the chevron at the left of the search bar to show or hide the replace row.
- Press
Escto close the search bar.
The bar shows the active match and the total count, for example 3/12. It shows No results when nothing matches.
Set search options
Two toggles sit next to the search field.
| Toggle | Button | What it does |
|---|---|---|
| Case sensitive | Aa | Match the exact letter case. Off by default. |
| Regex | .* | Read the query as a JavaScript regular expression. |
In regex mode, Prettify uses standard JavaScript regular expression syntax. An invalid expression matches nothing until you fix it.
"email":\s*"[^"]+@[^"]+"
Move between matches
Type a query, then step through the results.
- Press
Enterto go to the next match. - Press
Shift+Enterto go to the previous match. - Click the up and down arrows to do the same.
Search highlights every match in the current view and scrolls the active match into view.
Replace text
Open the replace row, then type a replacement.
- Type the text to find in the search field.
- Type the new text in the replace field.
- Press
Enter, or click the Replace button, to replace the active match. - Press
Shift+Enter, or click Replace All, to replace every match.
The Replace All button shows the number of matches it will change.
Replace edits the document text, so it runs the same way in every view. In regex mode, the replacement can use $1 for a capture group.
Prettify checks the result before it applies a replacement. If the change would make the document invalid, Prettify keeps the document and shows the message Replace would break format.
Search in each view
Search runs against the view you are in.
- Tree view matches keys and values.
- Table view matches cell values and column names, and highlights the matching rows.
- Raw view matches whole lines.
The match count can differ between views because each view counts different units: nodes, rows, or lines.
Keep a search in the URL
The left pane stores the search state in the page URL, so you can share or bookmark a search. These query parameters control it.
| Parameter | Meaning |
|---|---|
q | The search text. |
regex | true turns on regex mode. |
cs | true turns on case sensitivity. |
si | The index of the active match. |
Related
- Views: Tree, Table, Raw, and More
- jq queries for structural filters on JSON
- Keyboard shortcuts
Try it online
Tool pages for this topic. Each one runs in your browser.