How to store JSON on IPFS

Intro
Whether you’re building web3 applications or traditional applications, JSON is a fundamental building block. But what is JSON and where does it get stored? Let’s explore these questions as broadly as possible, but we’ll also narrow in on how JSON is especially applicable to web3 development.
What is JSON
JSON stands for JavaScript Object Notation. It is a data format that is especially compatible with the JavaScript programming language (which is native to web browsers), but it is also used in many other programming languages because it has become so ubiquitous.
JSON is a text-based data format stored as a string. It can contain flat-structured date or nested data. An example of a flat JSON structure might be:
And a nested version might look something like this:
As you can see from the examples above, JSON can present a virtually endless amount of data and in many different formats. This makes it incredibly flexible and powerful. It’s why so many APIs respond in JSON. It’s why so many app structures rely on it.
It’s also why web3, specifically NFTs and DeFi, have leaned so heavily into the world of JSON.
Why Does Web3 Use JSON?
If you came into the web3 world during the NFT boom, you may have been introduced to JSON for the first time even if you weren’t building anything. Every NFT had a record on the blockchain that pointed to a JSON file. That JSON file was like an API response in traditional applications. It told anyone looking at it everything they needed to know:
- What’s the name of this NFT?
- What’s the description?
- What attributes does it have?
- What media is associated with it?
- Etc
This JSON data did not live on-chain. It would be too expensive. But because NFTs are open, and blockchains are open, it’s important for the JSON and media to be open as well. This is why the vast majority of NFTs have JSON stored on IPFS.
We’ll dig into how to store JSON on IPFS, but we should also explore the world of DeFi and its ties to JSON.
DeFi tokens act very much like NFTs when it comes to data. The token itself lives on the blockchain. However, the token often has additional metadata associated with it. That data is in JSON form, and, by and large, it’s stored on IPFS. Protocols and apps building in the DeFi space also have orderbook data that they tend to need in an open format. So, guess what they do? They store this in JSON format and put it on IPFS.
How To Store JSON on IPFS
The first step to storing JSON on IPFS is to create the data that needs to be stored. If you’re an app developer, this is likely a natural byproduct of building your app and planning user data interactions. For example, a user registration form might have a name field, an organization field, and a how did you hear about us field. You would very likely represent those fields and the responses as JSON and then store that JSON somewhere.
Adding that JSON to the IPFS network is simple if you know what you’re doing. If you run your own IPFS node, you would make a network request to communicate with that node and tell it to pin the JSON to your node. This would then make the JSON available on the public IPFS network. However, running your own IPFS node is not always an option, and even if it is, you may wish to have redundancies for your data. That’s where a pinning service like Pinata can save you a ton of time.
If you’re not a developer, Pinata has a simple interface that allows you to upload content (like JSON!). Check out our guide on pinning a file to IPFS with Pinata here.
As a developer, though, you would likely be using the Pinata API to upload your content to the IPFS network through Pinata. Fortunately, we make this incredibly easy. Once you’ve created an API key, you should have no issue uploading. Here is a guide for uploading to Pinata through the API. Another benefit of using Pinata would be our SDK which makes uploading JSON a breeze.
Your JSON is on IPFS, Now What?
Once you’ve stored your JSON on IPFS, you will likely want to use that file for your application, NFT, DeFi project, or something else. Fortunately, the IPFS network is essentially a global CDN, making it easy to retrieve content if you know the content identifier (CID). Pinata makes this even faster and more reliable with Dedicated IPFS Gateways.
With a gateway and your CID, you can retrieve your JSON and use it anytime you want. The power of a global and open network is in the available and portability of data. IPFS powers that and Pinata makes it easy.
Happy pinning!
H1 - THE RICH TEXT
EXAMPLE STARTS HERE
H2 - Enabling Widespread Adoption for Music NFTs
paragraph — The first thing the music industry needs is more exposure. For artists, listeners and yeah, the labels. Even with the use cases mentioned above, the majority of the music industry still sees NFTs as a novelty rather than a legitimate way to run a business. We see a future where the experience is built and monetized on the blockchain, with labels taking part of the experience, as well.
Second, there needs to be a big jump in user experience. Listeners know what to expect with Spotify and Apple Music: a smooth, intuitive experience that lets them listen to Lil Nas X with just a few clicks. Web3 platforms aren’t quite there. Music NFTs and related premium content require extra steps that most people don’t yet have an appetite for.
H3 - How Could Music NFTs Save Artists?
paragraph — Musician Daniel Allan spent months building a relationship with the NFT community and raised 50 ETH to fund his new album, Overstimulated. Companies like Audius and artists like Vérité's, who raised $90,000 in an NFT launch, are at the forefront of exploring new ways to get paid. Avenged Sevenfold launched an NFT collection called "Deathbats Club" with 10,000 items that grants holders access to benefits such as meet and greets at shows, lifetime free tickets, limited edition merchandise, and more.

H4 - Static and dynamic content editing
A rich text element can be used with static or dynamic content. For static content, just drop it into any page and begin editing. For dynamic content, add a rich text field to any collection and then connect a rich text element to that field in the settings panel. Voila!
H5 — How to customize formatting for each rich text
Headings, paragraphs, blockquotes, figures, images, and figure captions can all be styled after a class is added to the rich text element using the "When inside of" nested selector system.
LINK — This is how a link looks like. Please provide normal & hover state (if different than this)
- This will be bullet points
- Numbered list is the same but with numbers
- It has a margin-left applied
- Headings, paragraphs, blockquotes, figures, images, and figure captions can all be styled after a class is added to the rich text element using the "When inside of" nested selector system.
- Headings, paragraphs, blockquotes, figures, images, and figure captions can all be styled after a class is added to the rich text element using the "When inside of" nested selector system.
- Headings, paragraphs, blockquotes, figures, images, and figure captions can all be styled after a class is added to the rich text element using the "When inside of" nested selector system.
QUOTE — Everyone is obsessed with making money and seeking alpha, which does a disservice to what [NFTs] can actually do. We have been instructing many bands that NFTs are a ticket for access to an exclusive club.” - M. Shadows, Avenged Sevenfold’s lead singer.