Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.


greek conversion for Python

A library that converts Ancient, Byzantine, and Modern Greek between Greek script, Beta Code, and Latin script, with atomic options composed into standards-based presets, and information-loss diagnostics.

PyPI CI License: MIT

Documentation · Playground


greek-conversion is a Python library for everyone who moves Greek between scripts:

  • Ancient Greek: read polytonic Greek with every mark, digamma, koppa, and sampi; transliterate an edition with its accents and length marks, or after SBL, the BnF, ALA-LC, or ISO 843; read and write the Beta Code of the TLG and Perseus.
  • Byzantine Greek, under the same conventions: read the breathings printed before capitals, the καί symbol, and alphabetic numerals; keep the lunate sigma, the overline of the nomina sacra, and Byzantine punctuation; romanize after ALA-LC, whose table runs to 1453.
  • Modern Greek: transcribe names as passports and maps write them, after ELOT 743, which the United Nations adopted and ISO 843 gives as its Type 2; transliterate after ISO 843 Type 1, which converts back, or ALA-LC; turn polytonic text into monotonic; build search keys and URL slugs.

Each convention is a preset: a set of the library's 52 atomic options, which states its references and how far it follows them. The options also combine beyond the presets, among 126 values: transliteration={"chi": "kh", "upsilon": "u"} writes ψυχή as psukhḗ, and greek={"iota_subscript": "adscript"} writes τῷ as τῶι. The ALA-LC, BnF, and ISO 843 presets are tested against examples from their published tables, and iso-843-type-2 against every example of the BGN/PCGN table. When a conversion cannot be reversed, the library says what was lost instead of quietly guessing. It converts whole corpora in one call.

The package is the Python distribution of the TypeScript library of the same name, and runs it: see How the package works.

Not a developer? The playground converts in the browser, with every preset and option, and shows what each conversion loses.

Installation

pip install greek-conversion

The package requires Python 3.11 or later. It is typed: every option key and value is known to editors and type checkers, which complete and check them (ConversionOptions, Preset, Format).

Main functions

You want to… Use
Convert a string convert(text, source, target, options)
Convert many strings at once: the lines of a corpus, a column convert_many(texts, source, target, options)
Normalize or restyle a string without changing its format reencode(text, format, options)
…for many strings at once reencode_many(texts, format, options)
Know whether the conversion loses information, and where each token went convert_detailed(text, source, target, options)
…for many strings at once convert_detailed_many(texts, source, target, options)
Convert only the Greek of a text in another language convert_greek_passages(text, target, options)
Bind a preset, add characters, or restrict the repertoire create_converter(configuration)

Options are given as a mapping, as keyword arguments, or both.

Examples

convert() / convert_many()

convert() takes a string from one format to another, after a preset or the options it is given:

>>> from greek_conversion import convert

>>> # The first words of the Odyssey, in the Beta Code of Perseus
>>> convert("ἄνδρα μοι ἔννεπε, μοῦσα", "greek", "beta-code")
'a)/ndra moi e)/nnepe, mou=sa'

>>> # A Byzantine manuscript's ligature for ου
>>> convert("τȣ̃ θεȣ̃", "greek", "transliteration")
'toũ theoũ'

>>> # A Modern Greek author, for a library record
>>> convert("Νίκος Καζαντζάκης", "greek", "transliteration", preset="ala-lc-modern")
'Nikos Kazantzakēs'

>>> # A search key, without marks or capitals
>>> convert("Ἀριστοτέλης", "greek", "transliteration",
...         diacritics={"all": "remove"},
...         transliteration={"long_vowels": "omit"},
...         text={"letter_case": "lowercase"})
'aristoteles'

convert_many() converts a list of strings as convert() converts each, in one call, which is much faster for the lines of a corpus or the cells of a column:

>>> from greek_conversion import convert_many

>>> convert_many(["μῆνιν ἄειδε", "Πηληϊάδεω Ἀχιλῆος"], "greek", "beta-code",
...              preset="tlg-core")
['MH=NIN A)/EIDE', '*PHLHI+A/DEW *)AXILH=OS']

convert_detailed() / convert_detailed_many()

convert_detailed() converts as convert() does, and says what the output cannot carry back, and where:

>>> from greek_conversion import convert_detailed

>>> # ISO 843 Type 2, which Greek passports use, writes eta like iota
>>> city = convert_detailed("Θεσσαλονίκη", "greek", "transliteration",
...                         preset="iso-843-type-2")
>>> city.output, city.lossy
('Thessaloníki', True)
>>> city.losses[0].message, city.losses[0].offset
('The target representation does not retain eta.', 10)

>>> # SBL's general style drops smooth breathings, accents, iota subscripts
>>> verse = convert_detailed("ἐν ἀρχῇ ἦν", "greek", "transliteration",
...                          preset="sbl-general")
>>> verse.output, len(verse.losses)
('en archē ēn', 6)

convert_detailed_many() gives, in one call, the result that convert_detailed() gives for each string of a list, and so tells which lose something:

>>> from greek_conversion import convert_detailed_many

>>> # Πάτρα has no eta to lose
>>> cities = convert_detailed_many(["Αθήνα", "Πάτρα", "Θεσσαλονίκη"], "greek",
...                                "transliteration", preset="iso-843-type-2")
>>> [(city.output, city.lossy) for city in cities]
[('Athína', True), ('Pátra', False), ('Thessaloníki', True)]

reencode() / reencode_many()

reencode() keeps the format and changes the spelling: it normalizes a text, or writes it after other conventions:

>>> from greek_conversion import reencode

>>> # The lunate sigma of an edition, made standard
>>> reencode("ϲοφίαϲ", "greek", greek={"sigma": "standard"})
'σοφίας'

>>> # Greek numerals, in figures
>>> reencode("ἔτει ͵αωκαʹ", "greek", text={"numerals": "decimal"})
'ἔτει 1821'

>>> # The Beta Code of Perseus, in the capitals of the TLG
>>> reencode("a)/ndra moi e)/nnepe, mou=sa", "beta-code", preset="tlg-core")
'A)/NDRA MOI E)/NNEPE, MOU=SA'

reencode_many() reencodes a list of strings as reencode() reencodes each, in one call:

>>> from greek_conversion import reencode_many

>>> # The lines of an edition, with standard sigmas
>>> reencode_many(["ἀρχὴ ϲοφίαϲ", "φόβοϲ θεοῦ"], "greek",
...               greek={"sigma": "standard"})
['ἀρχὴ σοφίας', 'φόβος θεοῦ']

How the package works

greek-conversion is first a TypeScript library, published on npm and JSR. This package runs that library, the reference implementation, in a JavaScript engine embedded in Python. It needs neither Node.js nor any other installation:

  • The same results. Outputs, losses, and positions are those of the library of the same version. On every change, they are compared with the library's own over more than a hundred thousand conversions.
  • The same versions. The package's version is the library's (1.0.0rc15 for 1.0.0-rc.15), followed by .postN for a fix of the Python package alone, and the stability policy applies to it as to the library.
  • The same documentation. The Python documentation is the library's, written in Python. In Python:
    • functions and option keys are written in snake_case (convert_detailed, long_vowels, beta_code, out_of_scope_behavior), as are the keys of the options and metadata returned, and the option names in errors; option values do not change ("grave-circumflex", "iso-843-type-2");
    • positions (offset, length, input_start…) count characters as Python does, so that text[loss.offset : loss.offset + loss.length] is the token;
    • results are frozen dataclasses; OptionError and CharacterScopeError are ValueErrors, with their details.
  • Prepared options and converters (prepare_options(), create_converter()) can be pickled and used in other processes, for instance with multiprocessing.

Engines

The package runs the library in one of two engines:

Engine Installed with Start One word A long text Many strings at once
QuickJS the package: quickjs-ng, a 2 MB wheel 70 ms 50 µs 10–20× Node 40 µs a word
V8 pip install "greek-conversion[v8]": mini-racer, 22 MB 130 ms 400 µs 1.4–3× Node 4 µs a word

quickjs-ng is the maintained fork of QuickJS: quick to start, and quick to call, so that it converts a word or a sentence at a time several times faster than V8. V8 is the engine of Chrome and Node: it converts almost as fast as Node, but each call waits for it, so that it is the quicker for long texts, and for lists of strings given at once to convert_many(), reencode_many(), or convert_detailed_many(). When mini-racer is installed, the package uses V8; choose otherwise with set_engine("quickjs") or the environment variable GREEK_CONVERSION_ENGINE. Performance gives the measures, and how to keep conversions fast.

Documentation

Every page of the site is also in Markdown, which python/llms.txt lists for the Python documentation.

Citing and license

If you use greek-conversion in research or in a published resource, please cite it; GitHub's “Cite this repository” button uses the metadata in CITATION.cff.

Copyright (C) 2021–2026 Antoine Boquet. Released under the MIT License. The greek-conversion logos are not covered by this license: all rights are reserved, as recorded in LicenseRef-greek-conversion-marks.

Metadata

Release files for greek-conversion 1.0.0rc16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for greek-conversion 1.0.0rc16
File Size Uploaded Provenance Actions
greek_conversion-1.0.0rc16.tar.gz 77.4 kB With provenance Details for greek_conversion-1.0.0rc16.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for greek-conversion 1.0.0rc16
File Interpreter ABI Platform Actions
greek_conversion-1.0.0rc16-py3-none-any.whl Python 3 none any Details for greek_conversion-1.0.0rc16-py3-none-any.whl

Total release size: 146.3 kB

Release files / greek_conversion-1.0.0rc16.tar.gz

Download URL greek_conversion-1.0.0rc16.tar.gz
Size 77.4 kB
Tags Source
SHA-256 checksum
How to use checksums
648c706c71734e337ac628aa578d0d5cd6c7ac6ca9f46b6ae0c955141c3140c2
BLAKE2b-256 checksum
How to use checksums
11b1f8143cb092d0b473d4c40c44ee870846323704dcb37ffc8f5c288450b8ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / greek_conversion-1.0.0rc16-py3-none-any.whl

Download URL greek_conversion-1.0.0rc16-py3-none-any.whl
Size 68.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d8547219234d7ee5de6d08ce28545750f856b4bf79aeb16669fc355e52d46bc
BLAKE2b-256 checksum
How to use checksums
5b7b496881750b2ce123485cc4f483392cf158557c6f0962e99fd3fef17146dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for greek-conversion 1.0.0rc16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for greek_conversion-1.0.0rc16.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page