You can make a string out of your JSON like this:

import json
json_str = json.dumps(r.json())

And then save it as a regular text file using standard methods.

with open(filename, 'w') as f:
    f.write(json_str)

EDIT: as pointed out in comments by @Tomalak, this code does double conversion, which is clearly not needed here. So you can just

with open(filename, 'w') as f:
    f.write(r.text)
Answer from Pavel Gurkov on Stack Overflow
🌐
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - If you followed along with the tutorial, then you’ve got a hello_frieda.json file that doesn’t contain newlines or indentation. Alternatively, you can download hello_frieda.json in the materials by clicking the link below: Free Bonus: Click here to download the free sample code that shows you how to work with JSON data in Python.
🌐
GitHub
github.com › justinbalaguer › python-json-url-download
GitHub - justinbalaguer/python-json-url-download: python script for downloading files from json data url
python script for downloading files from json data url - justinbalaguer/python-json-url-download
Author   justinbalaguer
🌐
Code Forum
codeforum.org › software & web development › back-end development › python
Python - Generate (and download) JSON file from hosted site using server side python | Code Forum - Where your coding journey begins
July 22, 2022 - However, the only way I can see this working would be to call a python script from the trigger that would update the json file. I did read somewhere that the database would need an extension for this to work, and I don't think that will be an option from the hosting company?
🌐
Python.org
discuss.python.org › python help
How can I download multiple .json files in one go from a site? - Python Help - Discussions on Python.org
August 12, 2023 - Hi all, I am using chatbase.co https://www.chatbase.co/ where I am hosting several chatbots. For each chatbot it is possible to download a .json file specified by a date interval which stores the chat conversation. Rig…
Find elsewhere
🌐
PyPI
pypi.org › project › jsons
jsons · PyPI
Details for the file jsons-1.6.3-py3-none-any.whl. Download URL: jsons-1.6.3-py3-none-any.whl · Upload date: Jun 9, 2022 · Size: 60.7 kB · Tags: Python 3 · Uploaded using Trusted Publishing? No · Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3 ·
      » pip install jsons
    
Published   Jun 09, 2022
Version   1.6.3
🌐
SourceForge
sourceforge.net › projects › json-py
json-py download | SourceForge.net
Download json-py for free. json.py is an implementation of a JSON (http://json.org) reader and writer in Python. jsontests.py are unit tests demonstrating the correctness of the implementation.
🌐
PyPI
pypi.org › project › jsonlib
jsonlib · PyPI
coerce_keys no longer attempts to determine the “JSON” format for a coerced value – it will simply call unicode(). ... Download the file for your platform.
      » pip install jsonlib
    
Published   Feb 09, 2010
Version   1.6.1
🌐
W3Schools
w3schools.com › python › python_json.asp
Python JSON
JSON is text, written with JavaScript object notation. Python has a built-in package called json, which can be used to work with JSON data.
🌐
Stack Overflow
stackoverflow.com › questions › 52781589 › how-to-download-the-json-content-using-python
How to download the json content using python - Stack Overflow
import requests import json response = requests.get('https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/datasets/bitly_usagov/example.txt') with open('pakka.txt', mode = 'wb') as file: file.write(response.content) f = 'pakka.txt' records = [json.loads(line) for line in open(f)] records[0] Hi guys - This code worked for me. Thanks for all the suggestions. ... import urllib.request resource = urllib.request.urlopen('https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/datasets/bitly_usagov/example.txt') content = resource.read().decode(resource.headers.get_content_charset()) ... import requests import json # docs.python.org/3/library/urllib.request.html#examples r = requests.get('raw.githubusercontent.com/wesm/pydata-book/2nd-edition/datasets/…) print(r) 2018-10-12T15:27:11.2Z+00:00
🌐
Salem State Vault
www-backup.salemstate.edu › home › finces › effortless guide: how to download json file quickly today
Effortless Guide: How to Download JSON File Quickly Today - Salem State Vault
May 29, 2025 - Using a command-line tool: If you're ... language: If you're a developer, you can use a programming language like Python or JavaScript to download JSON files programmatically....
🌐
GeeksforGeeks
geeksforgeeks.org › read-json-file-using-python
Read JSON file using Python - GeeksforGeeks
In the below code, firstly we import the JSON module, open the file using the file handling open() function, and then store the data into the variable 'data' using the json.load() function.
Published   April 2, 2025
🌐
Python Basics
pythonbasics.org › json
Working With JSON Data in Python - Python Tutorial
The object will then be converted to a python object. ... You can get JSON objects directly from the web and convert them to python objects.
🌐
Javatpoint
javatpoint.com › save-json-file-in-python
Save JSON File in Python - Javatpoint
Save json File in Python with tutorial, tkinter, button, overview, canvas, frame, environment set-up, first python program, etc.
🌐
Stack Abuse
stackabuse.com › how-to-get-json-from-a-url-in-python
How to Get JSON from a URL in Python
February 14, 2025 - In this article, we'll explore how to use Python to retrieve JSON data from a URL. We'll cover two popular libraries - requests and urllib, and show how to extract and parse the JSON data using Python's built-in json module.