Skip to main content

HomeAll guides

How to Use Stripe Test Card Numbers for Development and Testing

What Stripe test card numbers are and why developers use them

Stripe test card numbers are fake credit card numbers that Stripe provides so developers can test payment flows without charging real money. When you're building a website or app that accepts payments, you need to see how the payment form works, what happens when a transaction succeeds or fails, and how errors display to customers — all before you go live with real cards.

Stripe gives you two separate environments: a test mode and a live mode. Test mode uses fake card numbers and processes nothing to actual bank accounts. Live mode uses real cards and real money. You switch between them using different API keys, so there's no risk of accidentally charging a customer while you're still building.

Every test card number works only in test mode. If someone tries to use one of these numbers in your live environment, it will be rejected when ready. This separation is built into Stripe's system, not something you have to code yourself.

Key Takeaways

  • Stripe test card numbers work only in test mode and simulate different outcomes — successful charges, declined cards, and specific error types.
  • The most common test card is 4242 4242 4242 4242, which always succeeds; use other numbers to test declines and errors.
  • You can use any future expiration date, any three-digit CVC, and any five-digit ZIP code when testing.
  • Test transactions appear in your Stripe dashboard under test data, separate from live transactions, so you can review what happened without affecting real payments.
  • Different test card numbers trigger different responses — some simulate fraud blocks, others simulate insufficient funds — so you can test how your app handles each scenario.

The most common test card numbers and what they simulate

Stripe publishes a standard set of test card numbers on their documentation site. The number 4242 4242 4242 4242 is the default — it always succeeds, so use it to test the happy path where a payment goes through without problems. You can format it with spaces or dashes, or run it together; Stripe accepts all three.

To test what happens when a card is declined, use 4000 0000 0000 0002. This number will always fail with a "card declined" message. Use it to verify that your error message displays correctly and that the customer can try a different card without the form breaking.

Other test numbers simulate specific failure types. For example, 4000 0000 0000 9995 triggers an insufficient funds response, and 4000 0000 0000 9987 triggers a lost card response. Each one helps you test a different branch of your error handling code. Stripe's full list includes numbers for testing 3D find authentication, international cards, and other specialized scenarios.

The expiration date, CVC, and billing ZIP code don't matter in test mode — you can enter any future date, any three digits, and any five digits. Stripe ignores these fields when processing test transactions. This lets you focus on testing the payment logic itself rather than validation rules.

How to access test mode in your Stripe account

Log into your Stripe dashboard and look for a toggle in the top left corner labeled "Test mode" and "Live mode." Click the toggle to switch to test mode. Your entire dashboard view changes — the background color shifts slightly, and all the data you see is test data only.

In test mode, you'll see a separate set of API keys at the bottom of the Developers page. These are your test publishable key and test secret key. Use these keys in your code when you're building and testing. Never use your live keys during development, even by accident — if you do, real charges will go through.

When you switch back to live mode, you'll see your live API keys instead. The dashboard will show only real transactions. Many developers keep two browser tabs open — one in test mode for development, one in live mode for monitoring — so they don't accidentally use the wrong keys.

Testing different payment scenarios with test cards

Start by testing the success case: enter 4242 4242 4242 4242 in your payment form, submit it, and verify that the transaction appears in your Stripe dashboard under test data. Check that your success message displays, that the order confirmation email sends (if you have one), and that your database records the transaction correctly.

Next, test the decline case: enter 4000 0000 0000 0002 and verify that your error message appears on the form, that the customer can edit the card and try again, and that no partial transaction was created in your database. This is where many developers find bugs — the form might freeze, or the error message might be unclear.

Test at least one more scenario that's relevant to your business. If you process subscriptions, test what happens when a subscription renewal fails. If you handle refunds, test a refund and verify it appears in your dashboard. If you use webhooks to send confirmation emails, test that the webhook fires and the email arrives. Each scenario uses the same test card numbers but exercises a different part of your code.

Where test transactions appear in your dashboard

Open your Stripe dashboard and click "Payments" in the left menu. At the top, you'll see a filter that says "Live" or "Test." Make sure "Test" is selected. All the transactions you created with test card numbers will appear in this list, sorted by date with the most recent first.

Click on any test transaction to see its full details: the card number used, the amount, the timestamp, the status (succeeded, failed, or pending), and any error messages. If a transaction failed, the error message will tell you why — "card declined," "insufficient funds," or a specific code that Stripe uses internally.

Test transactions never affect your Stripe fees or your processing volume. Stripe doesn't count them toward your monthly transaction limit or charge you for them. They exist only so you can see how your integration works before you go live.

Common mistakes when testing with Stripe card numbers

The most common mistake is using live API keys during testing. If you do this, test card numbers will be rejected (which is correct), but if you accidentally use a real card number, it will be charged. Always double-check which keys you're using in your code before you deploy anything to production.

Another mistake is testing only the success case. Developers often verify that 4242 4242 4242 4242 works, then assume everything else will work too. But the error handling code — the part that runs when a card is declined or a 3D find challenge fails — is where bugs hide. Test at least one failure scenario before you go live.

A third mistake is forgetting to switch out of test mode before going live. If your site is still using test API keys after launch, real customers will see "card declined" errors even when their cards are valid. Check your API keys one more time before you deploy to production, and set up a monitoring alert that notifies you if test keys are being used in your live environment.

Moving from test mode to live mode

Before you switch to live mode, make sure you've tested the full payment flow: entering a card, submitting the form, seeing a success message, and verifying the transaction in your dashboard. Test at least one decline scenario too. If you use webhooks, test that they fire and your backend responds correctly.

When you're ready, replace your test API keys with your live API keys in your code. Update your environment variables or configuration file — don't hardcode the keys. Deploy the change to your production server. Stripe will start processing real transactions when ready.

After you go live, keep a test card handy for occasional spot checks. You can still use test mode in your Stripe dashboard to review how your integration works, but you won't be able to process test transactions through your live website. If you need to test something in production, use a small real transaction with a real card, then refund it when ready.

Frequently Asked Questions

Can I use test card numbers in live mode?

No. Stripe rejects test card numbers in live mode automatically. If you see "card declined" errors from test cards in production, it means your code is still using test API keys instead of live keys. Check your environment variables and redeploy.

Do test transactions show up in my Stripe fees or processing volume?

No. Test transactions are completely separate from your live data. Stripe doesn't charge you for them, doesn't count them toward your monthly volume, and doesn't include them in your revenue reports. They exist only for development.

What expiration date should I use for test cards?

Any future date works. Most developers use 12/25 or 12/99 out of habit, but Stripe doesn't validate the expiration date in test mode. Use whatever is easiest to remember or type.

Can I test 3D find or other advanced features with test cards?

Yes. Stripe provides specific test card numbers for 3D find, international cards, and other features. Check Stripe's documentation for the full list. Each number simulates a different scenario so you can test how your code handles it.

What happens if a customer accidentally uses a test card number on my live site?

Stripe will reject it with a "card declined" message, just like any other invalid card. The customer will see an error and can try a different card. No charge will go through, and no data will be stored.

This guide is for general information only and is not medical, financial, legal, or other professional advice. For decisions specific to your situation, consult a qualified professional. See our Editorial Policy.