A dynamic, client-side web application for calculating the total silver weight and melt value of a coin collection. The application is managed entirely through a simple CSV file, making it easy to add, update, and manage your coin list without touching the code.
- Dynamic Coin Loading: The entire coin list is loaded from an external
coins.csvfile. - Real-time Calculations: Total silver weight and melt value are calculated instantly as you input quantities.
- Individual Subtotals: See the melt value for each row of coins as you enter quantities.
- Editable Spot Price: Manually enter the current price of silver per troy ounce or per gram.
- Collapsible UI: Coins are grouped by country in clean, foldable sections for easy navigation.
- Advanced Search: A powerful search bar filters coins and countries in real-time, supporting multi-keyword searches (e.g., "UK Shilling").
- Persistent State: Your entered coin quantities are automatically saved in the browser's local storage, so they're there when you return.
- Dark & Light Themes: Includes a sleek theme switcher with sun/moon icons. The app also detects your system's preferred theme on the first visit.
- Robust Error Handling:
- CSV Validation: Checks
coins.csvfor invalid data (e.g., negative weights, incorrect columns) and displays clear warnings without crashing. - Precision Validation: Enforces that all
silverWeightvalues in the CSV have at least 6 decimal places. - Input Validation: Prevents negative values from being entered for prices or quantities.
- CSV Validation: Checks
- Utility Features: A "Clear All" button with a confirmation prompt to reset all quantities.
- Frontend: HTML, CSS, Vanilla JavaScript (no frameworks or libraries).
- Data Source: A local
coins.csvfile.
The project is self-contained. All files should be in the same directory.
/silver-coin-calculator/
├── index.html # The main HTML structure
├── style.css # All styling, including themes
├── script.js # All application logic and functionality
└── coins.csv # Your personal coin database
Because modern browsers restrict local file access for security reasons, you cannot simply open index.html directly. The project must be served by a local web server. The easiest way to do this is with Python.
-
Download Files: Place
index.html,style.css,script.js, andcoins.csvin a single folder. -
Populate Your Data: Open
coins.csvwith a text editor or spreadsheet program and add your coin data. See the Data Format section below for details. -
Start a Local Server:
- Open a terminal or command prompt.
- Navigate to the project folder where you saved the files.
- If you have Python 3 installed, run the following command:
python -m http.server
- This will start a local server, usually on port 8000.
-
Open the Application:
- Open your web browser (Chrome, Firefox, etc.).
- Go to the address:
http://localhost:8000 - The Silver Coin Calculator should now be running.
- Update Spot Price: If necessary, change the values in the "Silver Spot Price" section. The per-gram and per-ounce prices will stay in sync.
- Find Your Coins: Use the search bar to filter the list or click on a country name to expand its section.
- Enter Quantities: In the input box next to each coin, enter the quantity you own.
- View Totals: The Totals section at the top will update instantly, along with the individual subtotal for that coin row.
- Change Theme: Use the toggle switch in the header to switch between light and dark modes.
- Clear Data: Click the "Clear All Quantities" button to reset all inputs to zero.
This file is the heart of your application. It must follow a specific format.
- The first line must contain these header names (order is flexible):
country,name,date,grossWeight,purity,numistaUrl - Each subsequent line represents a single type of coin.
| Column | Description | Example | Validation Rules |
|---|---|---|---|
country |
The country of origin. Used for grouping. | USA |
Required. |
name |
The name of the coin. If the name includes a comma, it must be enclosed in double quotes. | Morgan Silver Dollar or "Florin, Circulated" |
Required. |
date |
The year or date range of the coin. This is treated as text. | 1916-1945 |
Required. |
grossWeight |
The total weight of the coin in grams. | 26.73 |
Required. Must be a positive number. |
purity |
The purity of the coin's silver content. Use a whole number (per mille) like 900 for 90%. |
900 (for 90%) or 835 |
Required. Must be a positive number between 1 and 1000. |
numistaUrl |
(Optional) A full URL to the coin's page on Numista. If empty, the coin name will not be clickable. | https://en.numista.com/... |
Optional. |
How Silver Weight is Calculated (and Displayed):
The application automatically calculates the pure silver weight using the formula:
Pure Silver Weight (grams) = grossWeight * (purity / 1000)
Pure Silver Weight (troy ounces) = Pure Silver Weight (grams) / 31.1034768
These calculated values, along with the coin's purity, are displayed in the coin list in the format:
(Purity‰ / Silver Weight in grams / Silver Weight in troy ounces)
e.g., (900‰ / 4.1750 g / 0.1342 tOz)
These calculated silverWeight_tOz values are used for all melt value calculations.
Example of Valid coins.csv content:
country,name,date,grossWeight,purity,numistaUrl
USA,Morgan Silver Dollar,1878-1921,26.73,900,https://en.numista.com/catalogue/pieces5325.html
UK,"Shilling, 92.5% Silver",1902-1919,5.65,925,https://en.numista.com/catalogue/pieces2747.html
Austria,1 Corona,1901-1916,5.0,835,This application is for informational and educational purposes only. The calculations are based on user-provided data (silver spot price and coin data in
coins.csv) and are intended as estimates.The spot price of silver is volatile and fluctuates constantly. The prices used in this calculator may not be real-time or accurate. All data, especially the silver weights in the
coins.csvfile, should be independently verified by the user.The author and contributors are not liable for any errors, inaccuracies, financial losses, or damages of any kind resulting from the use of this software. Use at your own risk.
Contributions are welcome! If you have ideas for new features, improvements, or have found a bug, please feel free to:
- Open an issue to discuss what you would like to change.
- Fork the repository and create a new branch (
git checkout -b feature/AmazingFeature). - Make your changes.
- Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
