</> ConvertAtlas Developer Tools
Bootstrap 5 · Intermediate

Credit Card Input Mask

A credit-card number input auto-formatted in groups, via Cleave.js.

Requires Bootstrap 5, Cleave.js. Add the CDN tags below to your page (styles in <head>, scripts before </body>). The downloaded file already includes them.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cleave.js@1.6.0/dist/cleave.min.js"></script>
<div class="card border-0 shadow-sm" style="max-width:320px"><div class="card-body"><label class="form-label small fw-semibold">Card number</label><input class="form-control" id="clCard" placeholder="0000 0000 0000 0000"></div></div>
new Cleave('#clCard',{creditCard:true});
Free to use.This component uses Bootstrap 5, Cleave.js (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.