Python Personal Diary Application Project

Python project 10

Python Personal Diary Application Project

Last updated: 31 August 2026

Build a private command-line diary that saves dated entries locally in JSON. It is a useful project for multi-line input, lists, dictionaries, local files, and responsible handling of personal data.

Practise Python file-based applicationsView all project ideas

What you will build

The app lets users add a multi-line diary entry, view previous entries, and save everything in a local diary.json file.

Skills practised

  • JSON files
  • datetime timestamps
  • Lists and dictionaries
  • Multi-line user input

Requirements

  • Python 3.8 or later
  • A terminal or command prompt
  • No external packages
  • About 30 minutes to build

Full Python code

Save it as personal_diary.py, then run it from a terminal.

"""A private command-line diary that stores entries locally in diary.json."""

import json
from datetime import datetime
from pathlib import Path

DIARY_FILE = Path("diary.json")


def load_entries():
    if not DIARY_FILE.exists():
        return []
    try:
        return json.loads(DIARY_FILE.read_text(encoding="utf-8"))
    except json.JSONDecodeError:
        print("The diary file could not be read. Starting with an empty diary.")
        return []


def save_entries(entries):
    DIARY_FILE.write_text(json.dumps(entries, indent=2, ensure_ascii=False), encoding="utf-8")


def add_entry(entries):
    print("Write your entry. Enter a blank line to save it.")
    lines = []
    while True:
        line = input()
        if not line:
            break
        lines.append(line)
    if not lines:
        print("Nothing was saved.\n")
        return
    entries.append({"created_at": datetime.now().strftime("%Y-%m-%d %H:%M"), "text": "\n".join(lines)})
    save_entries(entries)
    print("Diary entry saved.\n")


def view_entries(entries):
    if not entries:
        print("No diary entries yet.\n")
        return
    for index, entry in enumerate(reversed(entries), start=1):
        print(f"\n{index}. {entry['created_at']}\n{entry['text']}\n{'-' * 40}")


def main():
    entries = load_entries()
    print("Personal Diary (local file only)")
    while True:
        choice = input("1. Add entry  2. View entries  3. Quit: ").strip()
        if choice == "1":
            add_entry(entries)
        elif choice == "2":
            view_entries(entries)
        elif choice in {"3", "q", "quit", "exit"}:
            print("Diary closed. Keep diary.json private.")
            break
        else:
            print("Choose 1, 2, or 3.\n")


if __name__ == "__main__":
    main()

How it works

add_entry() collects lines until the user enters a blank one, then attaches a timestamp. Entries are written locally with ensure_ascii=False so normal Unicode characters remain readable.

Run the project

  1. Run python personal_diary.py.
  2. Choose 1 and write an entry.
  3. Enter a blank line to save it.
  4. Choose 2 to review saved entries, then keep diary.json private.

Notes for your notebook

  • Privacy: diary files may contain sensitive information.
  • Backups: save copies securely if the entries matter.
  • Encryption: is needed before treating a personal diary as a secure application.

Ways to extend it

Add search, mood tags, password-protected encryption with a reviewed library, or a desktop interface. Do not claim a plain JSON file is secure.

What to learn next

Strengthen your foundations through Python functions and choose another task from the Softenant project library.