~/projects/fetch-beautifier vscode extension
Fetch Beautifier
Turn "Copy as fetch" into code you'd actually keep.
DevTools' "Copy as fetch" gives you one long line with an encoded URL and a stringified body. Fetch Beautifier rewrites it into readable code, as a web tool or right inside VS Code.
Before
What DevTools copies.
fetch("https://example.com/api/search?q=shoes&filters=%7B%22size%22%3A42%2C%22color%22%3A%22red%22%7D", {"headers":{"content-type":"application/json"},"body":"{\"page\":1,\"limit\":20}","method":"POST"}); After
The same request, with the query string unpacked, the embedded JSON parsed and the body formatted.
const url = new URL("https://example.com/api/search")
url.search = new URLSearchParams([
["q", "shoes"],
["filters", JSON.stringify({
"size": 42,
"color": "red"
})],
]).toString()
fetch(url, {
method: "POST",
headers: {
"content-type": "application/json"
},
body: JSON.stringify({
"page": 1,
"limit": 20
}),
}) In VS Code
-
Paste and Format Fetch.
Cmd+Shift+V(Ctrl+Shift+Von Windows and Linux) pastes the clipboard already formatted. -
Format Fetch Code. Select a fetch call and press
Alt+Shift+F, or use the editor's context menu.
Code is formatted locally, in your browser or in VS Code. Nothing is sent anywhere.
Found a bug or want a feature? Open an issue or come say hi.
More VSCode extensions
All 3 → jf vscode
JSONPath Finder A VSCode extension for navigating complex JSON files with search and JSONPath expressions. vscode jv vscode
Joplin VSCode Plugin Provides the functionality to manage Joplin notes within VSCode vscode