Java EditorConfig Parser
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



License Maven Central Travis CI build status AppVeyor Windows CI build status

ec4j is an EditorConfig implementation for Java. It provides:

  • A parser for .editorconfig files

  • An API for querying EditorConfig properties applicable to a given file

  • A model of an editorconfig file rich enough to support validation, folding, code completion, etc. of .editorconfig files in editors and IDEs.

Who is using ec4j?

Here are some projects that use ec4j:

Basic usage

Add the following dependency to your project:

  <version><!-- check the latest on --></version>

To parse a single .editorconfig file into an EditorConfig model:

java.nio.file.Path editorConfigFile = Paths.get("path/to/my/.editorconfig");
EditorConfigParser parser = EditorConfigParser.builder().build();
EditorConfigModelHandler handler = new EditorConfigModelHandler(PropertyTypeRegistry.default_(), Version.CURRENT);
parser.parse(Resources.ofPath(editorConfigFile, StandardCharsets.UTF_8), handler, ErrorHandler.THROW_SYNTAX_ERRORS_IGNORE_OTHERS);
EditorConfig editorConfig = handler.getEditorConfig();

To query the properties applicable to a file in a source tree:

Cache myCache = ...; // e.g. Caches.permanent()
EditorConfigLoader myLoader = ...; // e.g. EditorConfigLoader.default_()
ResourcePropertiesService propService = ResourcePropertiesService.builder()
        .rootDirectory(ResourcePaths.ofPath(Paths.get("/my/dir"), StandardCharsets.UTF_8))

ResourceProperties props = propService.queryProperties(Resources.ofPath(Paths.get("/my/dir1/"), StandardCharsets.UTF_8));
IndentStyleValue indentStyleValue = props.getValue(PropertyType.indent_style,, true);
char indentChar = indentStyleValue.getIndentChar();
// Now you can e.g. check that /my/dir1/ is indented using indentChar

How to build


  • Java 7+

  • Optionally Maven 3.5.0+, unless you want to use ./mvnw or mvnw.bat delivered by the project

  • cmake 2.6+ to run the editorconfig-core-test testsuite (optional).

The most common build with unit tests:

./mvnw clean install

On Windows:

mvnw.bat clean install

A build with editorconfig-core-test testsuite:

git submodule init
git submodule update
mvn -Pcore-test clean install && ( cd core && cmake . && ctest . )

Relationship to editorconfig-core-java

The authors of ec4j decided to start ec4j because they were unsuccessful with their proposals in editorconfig-core-java.

Although ec4j is not a fork of editorconfig-core-java it uses a few portions of code from editorconfig-core-java. Such ones are clearly marked in ec4j 's JavaDoc.

ec4j aims at offering a superset of editorconfig-core-java 's functionality.

While editorconfig-core-java supports just the basic use case of querying the EditorConfig properties applicable to a given file, ec4j offers much more in addition to that:


  • All code and contributions are under Apache License

  • Issues and Discussions:

  • The ec4j/ec4j repository is the reference repository for contributing to ec4j.

  • Continuous integration is performed for each pull request by Travis CI on Linux and by AppVeyor on Windows.