Skip to content

JSON pretty-printing of request and response body #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dec1m0s
Copy link

@dec1m0s dec1m0s commented Jul 8, 2025

Overview

Burp automatically formats JSON data in request or response bodies. However, this is lost when copying the output.
This adds a new feature to the extension that uses a built-in method to parse JSON data and formats it before the text is copied to the clipboard.

image

Example

Without formatting:

GET /comments/1 HTTP/1.1
Host: dummyjson.com
Accept-Language: en-US,en;q=0.9
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Priority: u=0, i
Connection: keep-alive
Content-Length: 13

{"foo":"bar"}

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 133
Content-Type: application/json; charset=utf-8
Date: Tue, 08 Jul 2025 14:05:01 GMT
Etag: W/"85-FEb3h4CPX0SmhhGt/sXFy+BW+u4"
Server: railway-edge
Strict-Transport-Security: max-age=15552000; includeSubDomains
Vary: Accept-Encoding
[...]

{"id":1,"body":"This is some awesome thinking!","postId":242,"likes":3,"user":{"id":105,"username":"emmac","fullName":"Emma Wilson"}}

With formatting enabled:

GET /comments/1 HTTP/1.1
Host: dummyjson.com
Accept-Language: en-US,en;q=0.9
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Priority: u=0, i
Connection: keep-alive
Content-Length: 13

{
  "foo": "bar"
}

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 133
Content-Type: application/json; charset=utf-8
Date: Tue, 08 Jul 2025 14:05:01 GMT
Etag: W/"85-FEb3h4CPX0SmhhGt/sXFy+BW+u4"
Server: railway-edge
Strict-Transport-Security: max-age=15552000; includeSubDomains
Vary: Accept-Encoding
[...]

{
  "id": 1,
  "body": "This is some awesome thinking!",
  "postId": 242,
  "likes": 3,
  "user": {
    "id": 105,
    "username": "emmac",
    "fullName": "Emma Wilson"
  }
}

@tobiashort
Copy link
Contributor

Looked at the source code.
Have not the possibility to try it out yet.

Two thing come in my mind.

First, in case of copyFullHeaderPlusSelectedData only the request body is formatted, right? But not the partial response body. I think it should also be possible to format the partial response body, if what has been selected is a JSON node.

Second, your logic always tries to parse JSON even it is clearly not JSON. I think this is not ideal. Also, your code is very focused on JSON paring and so not extensible for other types of formatting like XML, HTML, etc. So I have the feeling that the code should be more generalized, like having a "Enable Body Formatting" option. And then have a formatBody function that first reads the Content-Type header and figures out what kind of formatting should be tried to be applied, like application/json -> JSON, application/xml or text/xml -> xml, text/html -> html (which is also xml I guess) etc. Then the code would be extensible if there is a need for other formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants