I'm reading JSON objects with jq and appending the value of fields to another file like so:

curl $JSON| jq '.body' | tee -a page1.md

This works great, however the markdown I'm extracting from the curl command is not formatting itself in page1.md. It's just appending, and not taking into account markdown styles such as ### which would bold text. For example, the line below is exactly what the command above is appending during a test run... Notice the quotes at the start and end of the line. All of this is outputted onto one line, ruining the integrity of the original markdown format extracted from the curl originally.

"###test test test \r\n**test test **\r\n\r\n> test test test test\r\n\r\n\r\test test test\n"

How can I append this text for markdown to read the formatting styles? I think the quotes are causing the problem?

  • Please show the original JSON file
    – White Owl
    Jun 8 at 22:18

1 Answer 1


The string holding the markup is stored encoded in the JSON document. Use jq -r instead of jq. This will give you the decoded ("raw") output, without the outer quotes.

Don't forget to double-quote your shell variables when you use them.

curl "$JSON" | jq -r '.body' >> page1.md
  • This is possibly the most straight forward answer. Thank you for the help!
    – andres
    Jun 8 at 22:28
  • Or jq -j .body for jq not to add an extra newline after the values (which already end in \n in the OP's sample). Jun 9 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.