languagetool-org/languagetool · error · IllegalArgumentException

JSON output format is not implemented for "line by line" ana

Error message

JSON output format is not implemented for "line by line" analysis

What it means

`--line-by-line` analyzes each line as an independent text, while JSON output is designed for whole documents with offsets. Combining them is not implemented, so when --json is parsed and lineByLine was already set, parseOptions() throws this IllegalArgumentException.

Source

Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java:142

        checkArguments("--bitextrules", i, args);
        options.setBitextRuleFile(args[++i]);
      } else if (args[i].equals("-c") || args[i].equals("--encoding")) {
        checkArguments("-c/--encoding", i, args);
        options.setEncoding(args[++i]);
      } else if (args[i].equals("-u") || args[i].equals("--list-unknown")) {
        options.setListUnknown(true);
        if (options.isTaggerOnly()) {
          throw new IllegalArgumentException("You cannot list unknown words when tagging only");
        }
      } else if (args[i].equals("-b")) {
        options.setSingleLineBreakMarksParagraph(true);
      } else if (args[i].equals("--json")) {
        options.setJsonFormat();
        if (options.isApplySuggestions()) {
          throw new IllegalArgumentException("JSON output format makes no sense for automatic application of suggestions");
        }
        if (options.isLineByLine()) {
          throw new IllegalArgumentException("JSON output format is not implemented for \"line by line\" analysis");
        }
        if (options.isBitext()) {
          throw new IllegalArgumentException("JSON output format is not implemented for Bitext");
        }
        if (options.isListUnknown()) {
          throw new IllegalArgumentException("You cannot list unknown words in JSON output format");
        }
      } else if (args[i].equals("-a") || args[i].equals("--apply")) {
        options.setApplySuggestions(true);
        if (options.isTaggerOnly()) {
          throw new IllegalArgumentException("You cannot apply suggestions when tagging only");
        }
        if (options.isJsonFormat()) {
          throw new IllegalArgumentException("JSON output format makes no sense for automatic application of suggestions");
        }
      } else if (args[i].equals("-p") || args[i].equals("--profile")) {
        options.setProfile(true);
        if (options.isJsonFormat()) {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Remove --line-by-line and let JSON output cover the whole file.
  2. Remove --json and use the default textual line-by-line output.
  3. Split the file yourself and run --json per chunk, merging results in your script.

Example fix

// before
languagetool --line-by-line --json -l en file.txt
// after
languagetool --json -l en file.txt
Defensive patterns

Strategy: validation

Validate before calling

List<String> a = Arrays.asList(args);
if (a.contains("--json") && (a.contains("--line-by-line") || a.contains("-lbyl"))) {
  throw new IllegalArgumentException("--json is incompatible with line-by-line mode");
}

Try / catch

try {
  new CommandLineParser().parseOptions(args);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("line by line")) {
    System.err.println("Drop --line-by-line or --json; they are not implemented together.");
  }
}

Prevention

When it happens

Trigger: `languagetool --line-by-line --json file.txt` — --line-by-line parsed before --json.

Common situations: Users processing line-oriented formats (CSV lines, logs) who also want structured JSON; batch scripts converting earlier line-by-line invocations to JSON output.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/0201aec91a0e218b. Report an issue: GitHub.