Password cell type
Use the password cell type to mask confidential values by rendering entered characters as symbols.
The password cell type masks cell values with asterisks. Use it for PIN codes, access codes, or other values that should not be visible in plain text.
Overview
The password cell type behaves like a text cell, the only difference being that it masks its value using asterisks in the cell renderer. An <input type="password"> field is used for the cell editor. Data is stored in the data source as plain text.
import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.registerAllModules();
const container = document.querySelector('#example1');
new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword', }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password' }], autoWrapRow: true, autoWrapCol: true,});import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.registerAllModules();
const container = document.querySelector('#example1')!;
new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword', }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password' }], autoWrapRow: true, autoWrapCol: true,});Fixed hash length
By default, every hash has a length equal to the length of its corresponding value. Use option hashLength to set a fixed hash length.
import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.registerAllModules();
const container = document.querySelector('#example2');
new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword', }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [ { data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password', hashLength: 10 }, ], autoWrapRow: true, autoWrapCol: true,});import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.registerAllModules();
const container = document.querySelector('#example2')!;
new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword', }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [ { data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password', hashLength: 10 }, ], autoWrapRow: true, autoWrapCol: true,});Custom hash symbol
By default, every hash consists of asterisks *. Use the option hashSymbol to set a custom hash symbol. You can use any character, entity, or even HTML. Note that you can’t change the symbol used by the input field due to browser limitations.
import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.registerAllModules();
const container = document.querySelector('#example3');
new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword', }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [ { data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password', hashSymbol: '■' }, ], autoWrapRow: true, autoWrapCol: true,});import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.registerAllModules();
const container = document.querySelector('#example3')!;
new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword', }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [ { data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password', hashSymbol: '■' }, ], autoWrapRow: true, autoWrapCol: true,});Reveal delay
Use the hashRevealDelay option to briefly show each character as you type it. After the delay (in milliseconds) elapses, the character is replaced by the hash symbol. This lets you confirm what you typed without permanently exposing the value.
When hashRevealDelay is set, the editor switches from a native <input type="password"> to a <input type="text"> field with manual masking. Only the most recently typed character stays visible - all preceding characters are already masked.
import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';// Register all Handsontable's modules.registerAllModules();const container = document.querySelector('#example4');new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword' }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [ { data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password', hashRevealDelay: 1000 }, ], autoWrapRow: true, autoWrapCol: true,});import Handsontable from 'handsontable/base';import { registerAllModules } from 'handsontable/registry';
// Register all Handsontable's modules.registerAllModules();
const container = document.querySelector('#example4')!;
new Handsontable(container, { data: [ { id: 1, name: { first: 'Chris', last: 'Right' }, password: 'plainTextPassword' }, { id: 2, name: { first: 'John', last: 'Honest' }, password: 'txt' }, { id: 3, name: { first: 'Greg', last: 'Well' }, password: 'longer' }, ], colHeaders: ['ID', 'First name', 'Last name', 'Password'], height: 'auto', // licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/ columns: [ { data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'password', type: 'password', hashRevealDelay: 1000 }, ], autoWrapRow: true, autoWrapCol: true,});Copy, cut, paste, and autofill
The password cell type sets the copyable option to false, so copy, cut, paste, and autofill don’t move a password value to the clipboard or to another cell. Each of these actions writes an empty value in its place:
| Action | What happens to a password cell |
|---|---|
| Copy | The clipboard gets an empty string for the cell. The previous clipboard content is replaced. In a range that also holds other cells, the password column copies as an empty column. |
| Cut | The cell is cleared, and the clipboard gets an empty string. You can’t paste the cut value anywhere. |
| Paste | The cell accepts pasted text like a text cell. Pasting a copied password cell writes an empty string, which clears the target cell. |
| Autofill | Dragging the fill handle from a password cell fills the target cells with empty strings, which clears them. In a range that also holds other cells, the other columns fill as usual and the password column is cleared. A double-click on the fill handle fills only empty cells, so it clears nothing. |
To restore a cleared value, use undo (Ctrl/Cmd+Z).
The data access methods still return the real value: getDataAtCell() and getSourceData() read the plain text stored in the data source. The copy-related methods follow copyable: getCopyableData() and getCopyableSourceData() return an empty string for a password cell, and the CopyPaste plugin’s copy() and cut() methods put an empty string on the clipboard.
The copyable option is not a security measure. It doesn’t hide the value from other features: with the formulas option enabled, a formula such as =B2 displays the plain password, and the ExportFile plugin exports the real value.
Keep passwords from being cleared
To stop autofill, paste, and cut from clearing password cells, skip those changes in the beforeChange hook. A skipped change leaves the cell’s value as it was:
beforeChange(changes, source) { if (!['Autofill.fill', 'CopyPaste.paste', 'CopyPaste.cut'].includes(source)) { return; }
changes.forEach((change, index) => { const [row, prop, , newValue] = change ?? [];
// autofill and paste write an empty string, cut writes `null` if (change && (newValue === '' || newValue === null) && this.getCellMetaTransient(row, this.propToCol(prop)).copyable === false) { changes[index] = null; } });},The hook reads the Handsontable instance from this, so pass it as a regular function or method, not as an arrow function. In React, Angular, or Vue, you can also read the instance from the component’s ref instead of this.
The hook protects every cell with copyable: false, not only password cells. It can’t tell a password’s empty value from a real empty value, so pasting an empty cell over a password cell, or filling down from an empty cell, is skipped too. With this hook, a user can still clear a password cell by editing it, or with Delete.
Result
After configuring the password cell type, cells display asterisks instead of the actual value. The editor uses an <input type="password"> field (or <input type="text"> when hashRevealDelay is set). The actual data is stored in plain text in the data source and is not encrypted by Handsontable DataGrid.
The Filters plugin’s Filter by value list hashes each unique source value the same way the cell renderer does, including a custom hashLength. A custom hashSymbol is applied as a string — the list paints labels as text nodes, so an HTML entity such as • appears as the characters •, not as a bullet. Filter by condition (for example Contains) and the search box at the top of the value list still match the source values, not the hashes.
Keyboard shortcuts
The password cell editor is a text editor, so it uses the standard edition keyboard shortcuts. It has no password-specific key bindings.
Related articles
Related guides
Configuration options
Core methods
Hooks