Debug log in readable format

Kindly let me know is there any option to get request and response in readable format with k6 for debugging purpose.

I’m using the below command to write into log :

k6 run --logformat=raw --http-debug=full .\Main.js 2> http_debug.txt

The problem I’m facing is the response I’m getting is in unreadable format:



¬LaÖ²╢g7¼æa╔╖ôÅ╢Uª÷q╣zffÖ├PTΣ$$m╞*▓╞ù╓JmKF'u6äÜ»╡¬PTΣ└ⁿy╕╜E₧╪δz«7║6;bÇ}┴ùû╥αyî┴a▐╤    ╬╦\ki╚Ot9"⌡¿ê╝ö¥bRxHCòm╜╢\XΦq�:┤J½OY⌠⌐ΦwδF:.Sá

¢ΩzeZ╩╛S│v⌐gD1-─ü¿H∞▐╦k╣íæv┬]½ò⌡-wtZ⌡δ]½(p+ΓP^Z:╖W√╥>^è7a·�vêó8q┌!┤≡╟╘c│tÜnCr#╙v┬}KeHßπW9∞XQo"  

q╓Q*)▌Θ∞ñ]ù¬TźÖe╒êjÄæV<ε{┘╨┴▀φ#U╜-ÄU,Yäa;c¡∙B╜J>╨æ╬1.Å],âRR¥ôV╦eµ╞U}¢φ8q╗|5/φ«D?xyS}₧|)║vª#ƒ╥₧   π╤Xαr#.╚αàe²µjú╣⌡WôêßR╢┴êb$╠g;╛Φú₧Ü|yîç6e├Q¼⌠RΦÆⁿp░;÷╓≥#ªq╙




How can I view something in readable way?

Any help here is appreciated. Thanks!!!

@mstoykov @imiric

Hi @divinp,

that looks like you’re logging a binary response, which will always look unreadable if you output it with --http-debug=full.

In these cases I would suggest logging the headers only (so just --http-debug), and selectively doing console.log(resp.body) on responses whose bodies you know are plain text (checking the Content-Type header, maybe).

@imiric : Most of my responses are not in text/html format, and mostly are in json and other formats, so how can I view the response of these requests.

If they’re in JSON then they should render OK with --http-debug=full.

If “other formats” includes binary data, then you’ll need to decode it appropriately depending on the format (Content-Type) and console.log() the plain text data. Again, --http-debug=full will not render these responses correctly as it doesn’t process the response bodies.

@imiric : The below snapshot is having content type as json but still its unreadable, I have given http-debug=full. Can u please help.

It looks like the content is brotli-encoded. Ideally, http-debug=full would decode the response but I suspect it is not (otherwise you would see the JSON in clear-text).

You may want to consider using a web proxy application like Fiddler, charlesproxy, mitmproxy, et. al, along with setting the https_proxy environment variable to the address that the proxy listens on. Doing so will route all requests through that proxy and allow you to view the HTTP request/response data in a more intuitive UI. They should also take care of any content encoding.


Thanks @Tom , do we have any documentation about setting http_proxy in k6?

For Linux, use:

$ export HTTPS_PROXY=https://localhost:<port>

For Windows and Powershell, use:


When you then run the k6 command (in the same terminal), you should see the requests appear in the web proxy tool.

1 Like

Thanks @Tom , it worked like charm.

Glad to see the proxy approach worked for you.

We’ve had a few issues with --http-debug so far (#986, #1042), and this is an additional one that doesn’t work as users expect it to, so I created #2112.

In upcoming versions we’d like to introduce a better way of debugging responses, see #1043, but it’s among a long list of wanted features, so feel free to give it a thumbs up in support. :slight_smile:

1 Like