Calculating crypto taxes manually is error-prone, especially when you’re transacting between centralized exchanges, DeFi pools, and multiple wallets. A crypto tax calculator helps to calculate capital gains and losses accurately, saving you time while lowering the risk of penalties. This free Crypto Tax Calculator Google Sheets template automatically fetches historical crypto prices using the CoinGecko API, calculates your capital gains and losses with the FIFO method, and separates them into Short-Term and Long-Term categories. The template provides a structured way to determine your tax liability from selling, swapping, or spending crypto, all based on accurate, verifiable historical data from the industry's most trusted source.
To get started and follow along with the setup steps, you can make a copy of the free Google Sheets template using the download link at the end of this article.
What is Crypto Tax?
Cryptocurrency is generally treated as property by tax authorities like the IRS, not as currency, which determines how various transactions are taxed.
Tax liability for crypto falls into two main categories:
-
Ordinary Income: If you are paid in cryptocurrency (e.g., salary, staking, mining rewards, or airdrops), the Fair Market Value (FMV) in USD at the time of receipt is taxed as ordinary income. These profits are taxed at your regular income tax rate, which can range from 10% to 37% in the United States of America.
-
Capital Gains/Losses: This tax applies when you dispose of crypto holdings, which includes selling for fiat, swapping crypto-to-crypto, or using it to buy goods or services. The taxable event is calculated by subtracting your Adjusted Cost Basis from the sale proceeds. For example, if you bought 1 ETH for $1,500 and later used that 1 ETH to buy a laptop when its value was $2,000, you've made a $500 capital gain that you need to report for tax purposes.
How Capital Gains and Losses Are Calculated
To calculate your Capital Gain/Loss, you must first determine the Cost Basis of the specific coins disposed of. Your cost basis is simply the original price you paid for an asset, and it is crucial for calculating the profit from any taxable transaction, such as selling or swapping crypto. Your final cost basis includes the original price plus any related transaction fees.
For example:
-
If you bought ETH for $2,000 and paid a $5 gas fee, your cost basis is $2,005.
-
If you later sell this ETH for $3,000, paying a $15 fee, your capital gain is calculated as:
$3,000 - $2,020 = $980 (where $2,020 is the total adjusted cost basis).
There are a number of different cost basis methods used in accounting. Depending on your tax jurisdiction and country, you may be entitled to select your preferred method. In the United States, for instance, the IRS allows taxpayers to choose methods like HIFO, FIFO, or LIFO, provided they can specifically identify the assets being sold. Whatever method you choose, you must use it consistently when calculating your gains or losses. If you are uncertain as to which cost basis method you can use, contact the IRS to confirm.
Note: This template is structured to comply with US tax laws and uses the FIFO (First-In, First-Out) method, the most common accounting approach, which assumes the first assets you acquired are the first ones you sell. This can be advantageous, as selling your longest-held assets may qualify them for lower long-term capital gains tax rates.
What Is the Difference Between Short-Term and Long-Term Crypto Taxes?
The primary difference is the tax rate you'll pay. The rate applied to your capital gain depends on how long you held the asset:
-
Short-Term Gains:
For crypto held for one year or less (Less than 365 days), the profit is taxed at the higher ordinary income tax rate (10% to 37% in the US). -
Long-Term Gains:
For crypto held for more than one year (More than 365 days), the profit is subject to preferential, lower tax rates (0% to 20% in the US).
Prerequisites
Before you start, ensure the following requirements are met to use the template effectively:
-
A Google Account:
You’ll need a Google account to open, copy, and use the template in Google Sheets. This allows you to save your own version and enable Apps Script for live data connections. -
A CoinGecko API Key:
Required to fetch live crypto prices. The free Demo API key is sufficient to get started, while a Pro plan offers higher rate limits for more frequent data refreshes. You can follow our guide to get your free Demo API key.
How to Use the Crypto Tax Calculator Google Sheet Template
This section provides a clear, step-by-step guide on how to integrate and use the Crypto Tax Calculator template effectively. Follow these instructions to set up your CoinGecko API key, input your transaction history, and view your automatically calculated tax summary.
Setting up the CoinGecko API Key in Google Sheets
First, connect the template to your CoinGecko API key. To do this, navigate to the “Read Me” sheet, this is your configuration page for API settings.
-
Open the “Read Me” sheet.
-
In cell A20, specify your subscription level as Demo or Pro.
-
In cell B20, paste your CoinGecko API key.
Once entered, the key is automatically recognized by all live queries across your workbook. You don’t need to modify any formulas manually.
Setting up Automatic Data Refreshes
Now that the API credentials are added to the spreadsheet, you can configure it to refresh the data automatically. Go to Extensions > Apps Script, then click the Triggers icon (shaped like a clock) on the left sidebar.

Clicking “+ Add Trigger” will open up a modal for you to configure the following settings:
-
Choose which function to run: triggerAutoRefresh
-
Choose which deployment should run: Head
-
Select event source: Time-driven
-
Select type of time based trigger: Minutes timer
-
Select minute interval: Every 5 or 10 minutes (note: anything less than this may not be useful, as results are cached)
Depending on your preferred frequency, you may also toggle between Hour timer, Day timer, or Week timer.
After saving, the script will run automatically at your specified interval, making sure all data is pulled correctly. Keep in mind that more frequent refreshes will consume your API call credits faster. If you run into rate limits, consider upgrading to a paid API plan for higher call credits and rate limits.
How to Add Specific Coins
To calculate historical values, the template needs the unique API ID for each asset, which you can find on any individual coin page on the CoinGecko website.

Once you have the API ID, simply paste it into cell B4 on the Tax Calculator Sheet. The template will then automatically fetch the correct historical data for your calculations.
Logging your Cryptocurrency’s Transactions in the Tax Calculator Sheet
Once the API key and coin ID are set up, you can begin logging your buy and sell transactions in the “Tax Transaction Log” table. This log is the foundation for calculating your cost basis and capital gains or losses using the FIFO method.
To log your transactions efficiently, you should import the data from your exchange history:
-
Export History from Your Source: Most crypto exchanges and centralized wallets allow you to download your complete transaction history as a CSV file. For on-chain data (e.g., from a MetaMask wallet), you can use a block explorer like Etherscan to view your address and download its transaction history.
-
Filter and Prepare Data: Open your exported CSV file and prepare the essential details required by the template's columns:
-
The Transaction Date and Time.
-
The Asset Name (e.g., "Bitcoin") to help you look up the correct CoinGecko API ID.
-
The Quantity purchased or sold.
-
The Transaction Fee, if applicable.
-
Whether the transaction was a Buy or a Sell.
-
Analyzing Your Crypto Tax Summary
Upon logging your transaction history appropriately, the in-built functions will start running immediately. The CoinGecko API will fetch the precise historical price for each transaction date, and the template will begin calculating your Capital Gains/Losses, separating them into Short-Term and Long-Term categories based on the FIFO method.

This system automatically transforms complex transaction data into auditable, tax-ready figures. You can use the Net FIFO Short-Term Gain and Net FIFO Long-Term Gain figures directly to complete your final tax forms, such as IRS Form 8949 and Schedule D.
To calculate your final tax liability, you must apply the appropriate tax rates to your Net FIFO Short-Term Gain and Net FIFO Long-Term Gain figures. Tax systems, like the one in the US, are often progressive, meaning different portions of your income are taxed at different rates (or 'brackets'). Your final tax payable is the sum of the taxes calculated for each bracket your gains fall into.
While the tax table in this template reflects US rates, the calculator's gain/loss figures can be used in any jurisdiction. Since FIFO is a widely accepted method, you can apply your country's specific tax rates to the net gains calculated by the sheet to determine your liability. To see an estimate of your U.S. federal income tax bracket, navigate to the Read me Sheet. Simply input your annual taxable income into Cell C20 and select your filing status from the dropdown menu in Cell D20.
The tax rate that automatically appears in Cell E20 is the Progressive Tax Rate Ceiling. This represents the highest marginal tax bracket your income falls into. Please note that this is not your effective tax rate and should not be used to calculate your final tax bill. It is an indicator of the highest tax rate applied to only the top portion of your income.
How to Create a Crypto Tax Calculator in Google Sheets
Creating a crypto tax calculator in Google Sheets involves three main components: a source for accurate historical price data, a structured log for transactions, and formulas to execute tax logic.
The template integrates all three seamlessly into one connected system:
-
Historical Crypto Price Data
Accurate historical prices are automatically fetched using a custom Google Apps Script function that communicates directly with the CoinGecko API. The template uses the dedicated/coins/{id}/historyendpoint to retrieve the Fair Market Value (FMV) of any asset on its specific transaction date, which is essential for establishing a reliable cost basis. -
Structured Transaction Logging
A detailed log sheet to record transaction input, such as quantities bought or sold, dates, and fees. -
Google Sheets Formulas and Tables
Advanced Sheets formulas are used to calculate and classify every taxable event instantly. These nested calculations determine the specific cost basis consumed by a sale, calculate the resulting Capital gain or loss, and classify it as Short-Term or Long-Term.
This connected system ensures that every metric, from your original cost basis to your final net gain, is calculated dynamically and accurately.
How to Get Historical Crypto Data in Google Sheets
You can get historical crypto data in Google Sheets by creating custom functions with Google Apps Script that fetches data directly from CoinGecko API’s /coins/{id}/history endpoint.
Step 1: Create an ImportJSON Script
First, create the main function that will fetch and parse data from CoinGecko API.
Open your Google Sheet and navigate to ‘Extensions’ and select ‘Apps Script’ - a new tab will appear.
On the left panel, select ‘< > Editor’ and add a new script using the ‘+’ button. Copy and paste the following importJSON script, and save the script as ‘ImportJSON’. This importJSON script is a versatile one that will allow you to import data in many different ways.
Step 2: Create the autoRefresh Script
Next, create a helper script that will allow the data to refresh automatically.
Create a second Apps Script by clicking on the ‘+’ button. Copy the code below and paste it into the script editor, saving it as ‘autoRefresh’ – this will allow your sheet to automatically refresh at fixed intervals.
Step 3: Call the Function in Your Sheet
With the scripts saved, you can now use the =IMPORTJSON() function in any cell.
-
Construct your CoinGecko API request URL.
-
Enter the formula into your desired cell, replacing the placeholder URL with your own.
For example, to get the price of Bitcoin on 30-12-2023, your formula would look like this:
=IMPORTJSON("https://api.coingecko.com/api/v3/coins/bitcoin/history?date=30-12-2023&x_cg_demo_api_key=YOUR_API_KEY,"/market_data/current_price/usd","noTruncate")This method is modular and powerful, as the =IMPORTJSON() formula can be easily replicated across any cell with different API endpoints. For a more detailed step-by-step guide, read our article on importing crypto prices into Google Sheets.
The Calculation Logic
Once your transaction data is logged, the spreadsheet automatically calculates your capital gains or losses using the core formula:
Proceeds - Adjusted Cost Basis = Capital Gain/Loss
Here’s a step-by-step breakdown of how the template applies this logic using the FIFO method:
-
Trigger Criteria:
When you log a "SELL" transaction, the formulas begin searching for the corresponding "BUY" transaction to determine the cost basis. -
Applying the FIFO Rule:
Following the First-In, First-Out rule, the template locates the earliest "BUY" transaction in your log that still has an unspent quantity. This is the specific "lot" being sold. -
Determine the Adjusted Cost Basis:
For that specific lot, the Adjusted Cost Basis is calculated by adding the original purchase price to any associated transaction fees
Purchase Price + Fees -
Calculate Gains or Loss:
The template then subtracts this Adjusted Cost Basis from your Sale Proceeds (the sale price minus any sale fees). The result is your realized capital gain or loss for that trade. -
Holding Period Categorization:
Finally, the template calculates the time between the purchase date and the sale date of that specific lot. If the period is more than 365 days, the gain or loss is categorized as Long-Term; if it is 365 days or less, it is categorized as Short-Term.
Common Issues & Fixes
If you encounter errors or missing data while using the tax calculator, here are a few common issues and how to resolve them quickly.
-
API Rate Limit (Error 429)
This happens when the free CoinGecko Demo API hits its request limit. Wait a few minutes before refreshing again, or switch to a Pro API key for uninterrupted updates.
If you receive other error codes, refer to the full list of CoinGecko API status codes to troubleshoot them. -
API Key or Endpoint Issues
If your API key isn’t connecting or you’re seeing Error 401 or Error 403:-
Confirm your API key and subscription level (demo or pro) are entered correctly in the Read Me sheet.
-
Ensure there are no extra spaces or formatting errors in the key.
-
-
Script Refresh Delays
If the data doesn’t refresh automatically, make sure your Apps Script trigger is active:-
Go to “Extensions” > “Apps Script” > “Triggers”.
-
Confirm that the “triggerAutoRefresh” function is scheduled to run every hour (or your preferred interval).
-
You can also manually click on “Run”, to force an immediate data refresh.
-
-
Inaccurate Gain/Loss Calculations
This happens when the transactions were not entered in chronological order, which breaks the sequential logic of the FIFO formulas. Sort your entire transaction log by date to ensure the FIFO engine works correctly:-
Click on the Downward arrow on the “Transactions Date & Time” Cell.
-
Navigate to “Sort Column” > “Sort A to Z”.
-
Further Enhancements
You can further enhance this Crypto Tax Calculator spreadsheet to better suit your needs. Here are a few ideas that leverage other CoinGecko API endpoints:
-
Fetch Historical Price Data
Pull Historical Prices for specific coins for more in-depth performance analysis. You can follow our guide on how to pull crypto historical data in Google Sheets and visualize long-term trends. -
Add OHLC (Open, High, Low, Close) Data
If you want more granular price insights, consider fetching OHLC data for each coin. Check out our step-by-step guide on how to pull crypto OHLC data into Google Sheets. -
Add a Crypto Portfolio Tracker
Extend the spreadsheet into a complete Crypto Portfolio Tracker to monitor unrealized P&L (the current profit/loss of assets you still hold) alongside your realized tax gains. For a full guide, see our article on how to create a crypto portfolio tracker in Google Sheets. -
Create a Crypto Exit Strategy Planner
To complement your tax planning, you can build a Crypto Exit Strategy Planner. Planning your exits strategically may help optimize your returns, which in turn impacts your final tax calculations. Check out our step-by-step guide on how to build a crypto exit strategy planner in Google Sheets.
Conclusion
A clear and auditable tax report is crucial for any crypto investor. This free Crypto Tax Calculator Google Sheets template, powered by the CoinGecko API offers a streamlined solution to determine your capital gains.
Reporting taxes with data from a reputable, industry-trusted source is essential to avoid potential discrepancies that invite scrutiny by tax authorities. Our template helps simplify the complex process of tracing asset cost basis across trades using reliable, aggregated historical data.
If you need more historical data beyond the Demo API's limits, higher rate limits and call credits, or access to exclusive endpoints, consider subscribing to a paid API plan.
Reminder: Consult a Tax Professional
Cryptocurrency tax regulations, particularly those involving DeFi and cross-border activity, are complex and constantly evolving. Users must be aware that crypto tax jurisdictions and methodologies vary by country or region. Confirm and apply the correct rules for your locale, and always consult a qualified tax professional to ensure accurate filing and to identify strategic tax optimization opportunities.
Download Your Free Template ⬇️
Subscribe to the CoinGecko Daily Newsletter!

Ethereum Mainnet
Base Mainnet
BNB Smart Chain
Arbitrum
Avalanche
Fantom
Flare
Gnosis
Linea
Optimism
Polygon
Polygon zkEVM
Scroll
Stellar
Story
Syscoin
Telos
X Layer
Xai