DEV Community

Cover image for Host Your JSON File in 2 minutes FOR FREE
Tala Amm
Tala Amm

Posted on

Host Your JSON File in 2 minutes FOR FREE

Many people ask: What is the best solution to host a simple JSON file and fetch it? Recently, I needed a place to host a JSON file without setting up a server, database, or paying for storage.

Turns out, if you have a GitHub account, you can use GitHub Gists.

1. Create a new Gist

Go to GitHub and from the dropdown choose Gists.

Github gists

Click on Create a Gist.

create a gist button

Give your file a name such as data.json, file description is optional.

2. Paste your data or upload it as a file from the button below.

adding json data

3. Save and Publish Gist

Before clicking on Create Gist, you can choose whether it's a Secret Gist or a Public Gist.

For JSON data hosting, choosing Secret Gist is better

But here is a Quick Comparison:

Feature Public Gists Secret Gists
Searchable? Yes, via search engines and GitHub (show up in "Discover" feed). No, completely unlisted.
Visible on Profile? Yes, visible to anyone visiting your profile. No, only visible to you when logged in.
Appears in Discover Feed? Yes, listed on the global feed. No.
Accessible via URL? Yes, anyone with the link can view it. Yes, anyone with the link can view it.
Best Used for Sharing useful code snippets, templates, or instructions with the developer community. Keeping personal work notes, saving scratchpad code, or sharing snippets with a limited audience.

⚠️ Crucial Security Warning
Secret gists are not secure vaults. If someone guesses, intercepts, or stumbles upon the URL of your secret gist, they can read all of its contents. Never store API keys, passwords, or confidential database credentials inside a secret gist. In fact, GitHub actively applies automated secret scanning to secret gists to catch leaked credentials.

public-secret-gists

GitHub will now host that file for you and keep a version history whenever you update it.

4. Get the Raw Link

Now the most important part.

Open your file and click Raw.

Raw button in gist

GitHub will redirect you to a URL that looks something like:

https://gist.githubusercontent.com/username/gist-id/raw/8c6f8d7f2d1a4f4f7f9f/data.json
Enter fullscreen mode Exit fullscreen mode

Notice that random-looking section after /raw/?

8c6f8d7f2d1a4f4f7f9f
Enter fullscreen mode Exit fullscreen mode

That's tied to a specific time version of your gist.

If you use that URL and later update your JSON, your application may keep fetching the old version.

Instead, remove the revision hash and keep only:

https://gist.githubusercontent.com/username/gist-id/raw/data.json
Enter fullscreen mode Exit fullscreen mode

Now every request will fetch the latest version of your file.

That's it!


Why I liked this:

  • Free hosting
  • Version history
  • No Backend
  • No Database
  • Easy to update
  • Public access through a URL

This works great for small datasets, configs, portfolios, mock APIs, and personal projects. If your JSON starts reaching tens of megabytes, you should probably consider a real storage solution rather than a Gist.

Sometimes the simplest backend is no backend at all 😄!

Top comments (0)