private static bool LooksLikeNdjson(string text, int threshold = 2) { int count = 0; using var sr = new StringReader(text); for (string line = sr.ReadLine(); line != null; line = sr.ReadLine()) { line = line.Trim(); if (line.Length == 0) continue; if (line.StartsWith("{") || line.StartsWith("[")) { if (++count >= threshold) return true; } else { // a non-JSON token breaks NDJSON expectation early break; } } return false; } private static JsonFormatDetector.Format ClassifyJsonHeader(string head) { // fingerprints if (head.IndexOf("\"type\":\"Topology\"", StringComparison.OrdinalIgnoreCase) >= 0 && head.IndexOf("\"objects\"", StringComparison.OrdinalIgnoreCase) >= 0) return JsonFormatDetector.Format.TopoJson; if (head.IndexOf("\"spatialReference\"", StringComparison.OrdinalIgnoreCase) >= 0 || head.IndexOf("\"geometryType\"", StringComparison.OrdinalIgnoreCase) >= 0 || head.IndexOf("\"attributes\"", StringComparison.OrdinalIgnoreCase) >= 0) return JsonFormatDetector.Format.EsriJson; if (LooksLikeNdjson(head)) return JsonFormatDetector.Format.GeoJsonSeq; // GeoJSON: FeatureCollection/Feature or geometry w/ coordinates if (head.IndexOf("\"FeatureCollection\"", StringComparison.OrdinalIgnoreCase) >= 0 || head.IndexOf("\"Feature\"", StringComparison.OrdinalIgnoreCase) >= 0 || head.IndexOf("\"coordinates\"", StringComparison.OrdinalIgnoreCase) >= 0) return JsonFormatDetector.Format.GeoJson; return JsonFormatDetector.Format.Unknown; } `` Then replace your current fallback block in Run(...) with: var head = ReadHeadUtf8(gisInputFilePath, maxBytes: 64 * 1024); // do not read whole file