This paper introduces a comprehensive C++ software package, HatchFrac, for stochastic modelling of fracture networks in two and three dimensions. Two main methods, the inverse CDF method and acceptance-rejection method, are applied to generate random variables from the stochastic distributions commonly used in discrete fracture network (DFN) modelling. The multilayer per-ceptron (MLP) machine learning approach, combined with the inverse CDF method, is implemented to generate random variables following any sampling distribution. To make the code faster, we extend the Newman-Ziff to determine clusters in the fracture networks. When combined with the block method, the Ziff algorithm improves the coding efficiency significantly. The software generates the T-type fracture intersections in the network, which can be used in applications involving fracture growth or incorporating geomechanics. We introduce three applications of HatchFrac that demonstrate the versatility of our software: percolation analysis, fracture intensity analysis, and flow and connectivity analysis.