Created
October 12, 2025 14:24
-
-
Save Kudusch/b83d29585c6247641c39d3c043e4438b to your computer and use it in GitHub Desktop.
Convert Minimalist password json to Bitwarden custom json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| import json | |
| in_file = sys.argv[1] | |
| with open(in_file, "r") as f: | |
| raw_items = json.load(f)["items"] | |
| raw_logins = [item for item in raw_items if item["category"] == "login"] | |
| logins = [] | |
| for login in raw_logins: | |
| raw_fields = login["fields"] | |
| fields = [] | |
| sections = {i["id"]:i["title"] for i in login["sections"] if "title" in i.keys()} | |
| for raw_field in raw_fields: | |
| if raw_field["category"] == "attachment": | |
| print(f"Warning: '{login['title']}' has attachment(s) that were not imported (Attachment directory: {raw_field["value"]})") | |
| if "value" in raw_field.keys() and raw_field["category"] != "attachment": | |
| try: | |
| fields.append({ | |
| "name":raw_field["title"] if "title" in raw_field.keys() else f"{raw_field['category']} ({sections[raw_field['sectionID']]})", | |
| "value":raw_field["value"], | |
| "type":1 | |
| }) | |
| except: | |
| pass | |
| logins.append({ | |
| "type": 1, | |
| "name": login["title"], | |
| "favorite": login["isFavorite"], | |
| "notes": login["notes"] if "notes" in login.keys() else None, | |
| "login": { | |
| "uris": [{ | |
| "match": None, | |
| "uri": login["website"] if "website" in login.keys() else None | |
| }], | |
| "username": login["username"] if "username" in login.keys() else None, | |
| "password": login["password"] if "password" in login.keys() else None, | |
| "totp": login["totpSecretKey"] if "totpSecretKey" in login.keys() else None | |
| }, | |
| "fields": fields | |
| }) | |
| raw_notes = [item for item in raw_items if item["category"] == "secureNote"] | |
| notes = [] | |
| for note in raw_notes: | |
| raw_fields = login["fields"] | |
| fields = [] | |
| for raw_field in raw_fields: | |
| if "title" in raw_field.keys() and "value" in raw_field.keys(): | |
| fields.append({ | |
| "name":raw_field["title"], | |
| "value":raw_field["value"], | |
| "type":1 | |
| }) | |
| notes.append({ | |
| "type": 2, | |
| "name": note["title"], | |
| "favorite": note["isFavorite"], | |
| "notes": note["notes"] if "notes" in note.keys() else None, | |
| "fields": fields, | |
| "secureNote": { | |
| "type": 0 | |
| } | |
| }) | |
| not_converted = [item for item in raw_items if not item["category"] in ["login", "secureNote"]] | |
| for item in not_converted: | |
| print(f"Warning: {item['title']} was not imported (unsupported category: {item['category']})") | |
| with open("converted.json", "w") as f: | |
| json.dump({"items":logins+notes}, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment