npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lasocietenouvelle/fec-reader

v1.0.1

Published

FEC parser — French accounting entries flat files (Fichier des Écritures Comptables)

Readme

@lasocietenouvelle/fec-reader

npm

Parser de fichiers FEC — Fichier des Écritures Comptables

Transforme un FEC brut en structure JSON exploitable : journaux, écritures groupées, comptes, période comptable.

Le FEC est un fichier normalisé produit par les logiciels de comptabilité et remis à l'administration fiscale (DGFiP) lors des contrôles. Il contient l'ensemble des écritures comptables d'un exercice.


Installation

npm install @lasocietenouvelle/fec-reader

Requiert Node.js ≥ 20. Package en ES Modules uniquement ("type": "module" dans votre package.json).


Utilisation

Node.js

import { readFileSync } from 'fs';
import { FECReader } from '@lasocietenouvelle/fec-reader';

const buffer = readFileSync('./mon-fichier.txt');  // pas d'encodage — Buffer brut

try {
  const result = FECReader(buffer);  // encodage auto-détecté

  console.log(result.Metadonnees.Periode);
  // { DateDebut: '20240101', DateFin: '20241231' }

  console.log(Object.keys(result.Journaux));
  // [ 'AN', 'ACH', 'VTE', 'OD' ]

} catch (error) {
  console.error('Erreur de parsing FEC :', error.message);
}

Navigateur

import { FECReader } from '@lasocietenouvelle/fec-reader';

input.addEventListener('change', async (e) => {
  const buffer = await e.target.files[0].arrayBuffer();
  const result = FECReader(buffer);  // encodage auto-détecté
});

Formats acceptés

| Critère | Valeurs acceptées | |---------|-------------------| | Extensions | .txt, .csv | | Encodage | Auto-détecté — UTF-8 (avec ou sans BOM), Windows-1252 / ISO 8859-15, ASCII | | Séparateur | Tabulation \t ou pipe \| | | Colonnes montant | Debit / Credit (format standard) ou Montant / Sens (format alternatif — converti automatiquement) |

Les colonnes Montant et Sens sont automatiquement converties en Debit et Credit.

Les dates sont conservées au format source YYYYMMDD (format DGFiP).


API

FECReader(input)

Parse le contenu d'un fichier FEC et retourne la structure JSON décrite ci-dessous.

Paramètre :

| Nom | Type | Description | |-----|------|-------------| | input | string \| Buffer \| ArrayBuffer \| Uint8Array | Contenu du fichier FEC — les octets bruts sont auto-décodés |

Retour : un objet FECData.

Erreurs levées :

| Condition | Message | |-----------|---------| | Type d'entrée invalide | FECReader : paramètre invalide (string, Buffer ou ArrayBuffer attendu) | | Séparateur non reconnu | Séparateur non reconnu (attendu : tabulation ou pipe) | | Colonnes obligatoires manquantes | Fichier erroné (libellé(s) manquant(s) : <colonnes>) | | Ligne avec colonnes manquantes | Fichier FEC incomplet — colonne(s) manquante(s) à la ligne N : <colonnes> | | Ligne avec trop de colonnes | Fichier FEC invalide — trop de colonnes à la ligne N | | Fichier corrompu | Le fichier FEC semble corrompu ou mal exporté (ligne N : X colonne(s) lue(s) sur Y attendues) |


Structure de sortie

FECData

| Propriété | Type | Description | |-----------|------|-------------| | Journaux | Record<string, Journal> | Journaux comptables indexés par code journal | | Comptes | Record<string, Compte> | Comptes généraux indexés par numéro de compte | | ComptesAux | Record<string, Compte> | Comptes auxiliaires (tiers) indexés par numéro | | Metadonnees.Periode.DateDebut | string \| null | Date de début de période (YYYYMMDD) | | Metadonnees.Periode.DateFin | string \| null | Date de fin de période (YYYYMMDD) | | Metadonnees.Fichier.Encodage | string | Encodage détecté (UTF-8, UTF-8 BOM, Windows-1252) | | Metadonnees.Fichier.Separateur | string | Séparateur détecté (\t ou \|) | | Metadonnees.Fichier.Format | string | Format détecté (standard ou avecSens) |

Journal

| Propriété | Type | Description | |-----------|------|-------------| | Libelle | string | Libellé du journal | | NombreEcritures | number | Nombre total d'écritures | | NombreLignes | number | Nombre total de lignes d'écriture | | DerniereDate | string | Date de la dernière écriture du journal (YYYYMMDD) | | Ecritures | Record<string, Ecriture> | Lignes regroupées par numéro d'écriture |

Ecriture

| Propriété | Type | Description | |-----------|------|-------------| | EcritureDate | string | Date d'écriture (YYYYMMDD) | | Lignes | Record<string, LigneEcriture[]> | Lignes regroupées par numéro d'écriture |

LigneEcriture

Champs conformes à la norme DGFiP. JournalCode, JournalLib, EcritureDate, EcritureNum, CompteLib et CompAuxLib sont omis — ils sont portés par la structure (Journaux["ACH"], Ecritures["AC0001"]) ou disponibles via Comptes[CompteNum] et ComptesAux[CompAuxNum].

| Champ | Type | Description | |-------|------|-------------| | CompteNum | string | Numéro de compte général | | CompAuxNum | string | Numéro de compte auxiliaire (tiers) | | PieceRef | string | Référence de pièce justificative | | PieceDate | string | Date de la pièce (YYYYMMDD) | | EcritureLib | string | Libellé de l'écriture | | Debit | number | Montant débit | | Credit | number | Montant crédit | | EcritureLet | string | Code de lettrage | | DateLet | string | Date de lettrage (YYYYMMDD) | | ValidDate | string | Date de validation (YYYYMMDD) | | MontantDevise | string | Montant en devise d'origine | | IDevise | string | Code devise (ex : EUR, USD) |

Compte

| Propriété | Type | Description | |-----------|------|-------------| | Libelle | string | Libellé du compte |


Licence

EUPL-1.2 — La Société Nouvelle


Support et contribution

Pour signaler un bug ou proposer une amélioration :