enpass-to-1password


README

Enpass JSON to 1Password CSV

Enpass has decided not to offer CSV export anymore with version 6 (current status: February 2019). This is annoying because the generated Enpass JSON export file can neither be read in 1Password nor in Dashlane. ut since most password managers can import the 1Password CSV format, it seemed practical to me if there is a simple converter. his script is based on Migvill's enpass-to-csv script. I only adapted his global CSV adjustments to the 1Password format.

Requirements

Installation

  1. Open your CLI and navigate to the downloaded folder
  2. npm install

Usage

  1. Export your Enpass 6 vault into json format from the desktop application. It is possible that the app language has to be set to English first.
  2. Copy the JSON file into the folder with the script
  3. Convert your data
  4. Import the generated CSV file into 1password. Or dashlane. Or Whatever.

Note: Only elements with the types "Login", "Password" and "Uncategorized" are converted. Whereby "Uncategorized" worked for me, but I can imagine that it can lead to problems for others here.

During the conversion, all unconverted elements are displayed in the console. These can then be maintained manually. Optionally this log can be saved to a text file.

node convert.js enpass.json 1password.csv | tee NotConvertedItems.txt

Disclaimer

Use at own risk. Please verify the csv output yourself before importing to another password manager

# 
> const fs = require('fs');
const args = process.argv;
const inputFile = args[2] || 'vault.json';
const outputFile = args[3] || 'vault.csv';

console.log('\nREADING: ' + inputFile + '\n');

try {
    const contents = fs.readFileSync(inputFile);
    const vault = JSON.parse(contents);
    let notConverted = 0;
    let converted = 0;

    const csvOutput = ['title,website,username,password,notes,category'];
    const fieldMapping = {
        title: 'title',
        url: 'website',
        username: 'username',
        password: 'password',
        notes: 'notes',
        category: 'category'
    };

    vault.items.forEach(item => {
        if (
            item.category === 'login'
            || item.category === 'password'
            || item.category === 'uncategorized'
        ) {
            const rowData = {
                title: item.title,
                website: '',
                username: '',
                password: '',
                notes: item.note,
                category: item.category
            };

            Object.keys(fieldMapping).forEach(type => {
                const key = fieldMapping[type];
                if (item.fields !== undefined) {
                    item.fields.forEach(field => {
                        if (field.type === type) {
                            if (field.value && !rowData[key]) {
                                if (field.value === 'url') {
                                    rowData['website'] = '"' + field.value + '"'; 
                                } else {
                                    rowData[key] = '"' + field.value + '"';
                                }
                            }
                        }
                    });
                } 
            });

            csvOutput.push(
                Object.keys(rowData)
                .map(key => rowData[key])
                .join(','),
            );

            converted++
        } else {
            notConverted++
            console.log('NOT CONVERTED: ', item.title, ' - ', item.category)
        }
    });

    console.log('WRITING: ' + outputFile + '\n');
    console.log('SUCCESSFUL: ', converted, ' items. ')
    console.log('FAILED: ', notConverted, ' items. ')
    fs.writeFileSync(outputFile, csvOutput.join('\n'));
} catch (err) {
    throw err;
}