Skip to content

Build your personal knowledge base with Trilium Notes

feat(import): readable title for untitled Google Keep notes

Elian Dorane602ec50cf1f
diff --git a/packages/trilium-core/src/services/import/keep/importer.spec.ts b/packages/trilium-core/src/services/import/keep/importer.spec.ts
index 9ebf51c01f..07b1796fe6 100644
--- a/packages/trilium-core/src/services/import/keep/importer.spec.ts
+++ b/packages/trilium-core/src/services/import/keep/importer.spec.ts
@@ -21,12 +21,19 @@ describe("Google Keep importer — parseNote", () => {
});
});
- it("falls back to the (timestamp) filename for an untitled note", () => {
+ it("derives a readable local-time title from the timestamp filename for an untitled note", () => {
const json = JSON.stringify({ title: "", textContent: "Dsaa" });
const note = parseNote("2025-11-13T23_39_37.236+02_00.json", json);
- expect(note?.title).toBe("2025-11-13T23_39_37.236+02_00");
+ // Reformatted to local wall-clock time (the offset is already baked into the filename).
+ expect(note?.title).toBe("2025-11-13 23:39:37");
+ });
+
+ it("uses a non-timestamp filename as-is for the title", () => {
+ const note = parseNote("Shopping list.json", JSON.stringify({ title: "", textContent: "milk" }));
+
+ expect(note?.title).toBe("Shopping list");
});
it("renders a multi-line body as one paragraph per line, escaping HTML", () => {
diff --git a/packages/trilium-core/src/services/import/keep/importer.ts b/packages/trilium-core/src/services/import/keep/importer.ts
index f01ea895eb..bb3e98cb13 100644
--- a/packages/trilium-core/src/services/import/keep/importer.ts
+++ b/packages/trilium-core/src/services/import/keep/importer.ts
@@ -97,9 +97,9 @@ export function parseNote(path: string, json: string): ParsedNote | null {
return null;
}
- // Untitled Keep notes export with an empty `title`; their filename is the note's timestamp, which at
- // least keeps them distinguishable.
- const title = note.title?.trim() || removeExtension(baseName(path)) || "Untitled";
+ // Untitled Keep notes export with an empty `title`; fall back to a readable title derived from the
+ // timestamp filename.
+ const title = note.title?.trim() || formatUntitledTitle(removeExtension(baseName(path)));
return {
title,
@@ -212,6 +212,21 @@ function usecToUtc(usec: number | undefined): string | undefined {
return Number.isNaN(date.getTime()) ? undefined : dateUtils.utcDateTimeStr(date);
}
+/**
+ * Builds a readable title for an untitled note from its filename. Keep names untitled notes by their
+ * timestamp with the local-time offset baked in (e.g. "2026-06-21T11_14_14.438+03_00"); reformat that to
+ * "2026-06-21 11:14:14" — the digits before the offset are already local, so no conversion is needed.
+ * Non-timestamp names are returned as-is, and an empty name falls back to "Untitled".
+ */
+function formatUntitledTitle(name: string): string {
+ const match = name.match(/^(\d{4}-\d{2}-\d{2})T(\d{2})_(\d{2})_(\d{2})/);
+ if (match) {
+ const [, date, hour, minute, second] = match;
+ return `${date} ${hour}:${minute}:${second}`;
+ }
+ return name || "Untitled";
+}
+
function escapeHtml(text: string): string {
return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}